Package org.jppf.utils
Class TraversalList<E>
java.lang.Object
org.jppf.utils.TraversalList<E>
- Type Parameters:
E- The element type for this list.
- All Implemented Interfaces:
Serializable
A list that maintains and manages a current position and corresponding current element.
- Author:
- Laurent Cohen
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionDefault initialization.TraversalList(List<E> list) Initialize this traversal list with a specified list with the same element type. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a new element to the list.booleanDetermine whether this traversal list contains a specified element.voidIncrement the current position by 1.booleanReturn the element at the current position in the list.getFirst()Get the first element in the list.getLast()Get the last element in the list.getList()Get the list of elements of this traversal list.intGet the current position in the list.inthashCode()voidIncrement the current position by 1.voidsetPosition(int pos) Set the current position in the list.intsize()Get the number of elements in this traversal list.toString()
-
Constructor Details
-
TraversalList
public TraversalList()Default initialization. -
TraversalList
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
Add a new element to the list.- Parameters:
element- the element to add.
-
getFirst
Get the first element in the list.- Returns:
- the first element.
-
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
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
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
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
-
equals
-
hashCode
public int hashCode()
-