org.jppf.utils
Class TraversalList<E>

java.lang.Object
  extended by 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:
Serialized Form

Constructor Summary
TraversalList()
          Default initialization.
TraversalList(List<E> list)
          Initialize this traversal list with a specified list with the same element type.
 
Method Summary
 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 decPosition()
          Increment the current position by 1.
 E getCurrentElement()
          Return the element at the current position in the list.
 E getFirst()
          Get the first element in the list.
 E getLast()
          Get the last element in the list.
 List<E> getList()
          Get the list of elements of this traversal list.
 int getPosition()
          Get the current position in the list.
 void incPosition()
          Increment the current position by 1.
 void setPosition(int pos)
          Set the current position in the list.
 int size()
          Get the number of elements in this traversal list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

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 Detail

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 lsit 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 lsit 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.


Copyright © 2005-2010 JPPF Team.