Class TraversalList<E>

java.lang.Object
org.jppf.utils.TraversalList<E>
Type Parameters:
E - The element type for this list.
All Implemented Interfaces:
Serializable

public class TraversalList<E> extends Object implements Serializable
A list that maintains and manages a current position and corresponding current element.
Author:
Laurent Cohen
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    Default initialization.
    Initialize this traversal list with a specified list with the same element type.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(E element)
    Add a new element to the list.
    boolean
    contains(E element)
    Determine whether this traversal list contains a specified element.
    void
    Increment the current position by 1.
    boolean
     
    Return the element at the current position in the list.
    Get the first element in the list.
    Get the last element in the list.
    Get the list of elements of this traversal list.
    int
    Get the current position in the list.
    int
     
    void
    Increment the current position by 1.
    void
    setPosition(int pos)
    Set the current position in the list.
    int
    Get the number of elements in this traversal list.
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • TraversalList

      public TraversalList()
      Default initialization.
    • TraversalList

      public TraversalList(List<E> list)
      Initialize this traversal list with a specified list with the same element type.
      Parameters:
      list - a list with the same element type as this traversal list.
  • Method Details

    • add

      public void add(E element)
      Add a new element to the list.
      Parameters:
      element - the element to add.
    • getFirst

      public E getFirst()
      Get the first element in the list.
      Returns:
      the first element.
    • getLast

      public E getLast()
      Get the last element in the list.
      Returns:
      the last element.
    • incPosition

      public void incPosition()
      Increment the current position by 1.
    • decPosition

      public void decPosition()
      Increment the current position by 1.
    • getList

      public List<E> getList()
      Get the list of elements of this traversal list.
      Returns:
      an unmodifiable copy of the list.
    • getPosition

      public int getPosition()
      Get the current position in the list.
      Returns:
      the position as an int value, -1 if the list is empty.
    • setPosition

      public void setPosition(int pos)
      Set the current position in the list.
      Parameters:
      pos - the position as an int value, -1 if the list is empty.
    • getCurrentElement

      public E getCurrentElement()
      Return the element at the current position in the list.
      Returns:
      the element at the current position.
    • size

      public int size()
      Get the number of elements in this traversal list.
      Returns:
      the size of the list as an int value.
    • contains

      public boolean contains(E element)
      Determine whether this traversal list contains a specified element.
      Parameters:
      element - the element to lookup.
      Returns:
      true if this list contains the element, false otherwise.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object