org.palo.api.impl.utils
Class ArrayListInt.ListIterator

java.lang.Object
  extended by org.palo.api.impl.utils.ArrayListInt.Iterator
      extended by org.palo.api.impl.utils.ArrayListInt.ListIterator
Enclosing class:
ArrayListInt

public class ArrayListInt.ListIterator
extends ArrayListInt.Iterator

ArrayListInt.ListIterator is a bidirectional iterator with basic versioning. This versioning functionality will warn when the arraylist the iterator is associated with has been modified since the point in time when the iterator was instanciated. However this mechanism implemented by a simple counter is not sufficient for detecting shared-memory modifications done by concurrently executing threads. This is only possible to achieve by using synchronization constructs throughout the usage of the list/iterator pair, as the synchronization constructs are the only way of making sure that the independant working memory of each thread is flushed back into main memory. The ArrayListInt.ListIterator iterator is capable of iterating backwards and forwards through the arraylist it is associated with.


Method Summary
 boolean hasNext()
          Tests whether there is a next element after the current element that the iterator points to.
 boolean hasPrevious()
          Tests whether there is a previous element before the current element that the iterator points to.
 int next()
          Returns the next element from the iterator.
 int nextIndex()
          Returns the index of the next element in the arraylist.
 int previous()
          Returns the previous element from the iterator.
 int previousIndex()
          Returns the index of the previous element in the arraylist.
 void set(int element)
          Sets the element at which the iterator is currently pointing.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

nextIndex

public int nextIndex()
Returns the index of the next element in the arraylist.

Returns:
next index
Throws:
ListModifiedException - thrown if a modification of the array was detected.

previousIndex

public int previousIndex()
Returns the index of the previous element in the arraylist.

Returns:
previous index
Throws:
ListModifiedException - thrown if a modification of the array was detected.

hasPrevious

public boolean hasPrevious()
Tests whether there is a previous element before the current element that the iterator points to.

Returns:
true if there is an element previous before the current element.
Throws:
ListModifiedException - thrown if a modification of the array was detected.

hasNext

public boolean hasNext()
Tests whether there is a next element after the current element that the iterator points to.

Overrides:
hasNext in class ArrayListInt.Iterator
Returns:
true if there is an element next after the current element.
Throws:
ListModifiedException - thrown if a modification of the array was detected.

previous

public int previous()
Returns the previous element from the iterator.

Returns:
the previous element
Throws:
ListModifiedException - thrown if a modification of the array was detected.

next

public int next()
Returns the next element from the iterator.

Overrides:
next in class ArrayListInt.Iterator
Returns:
the next element
Throws:
ListModifiedException - thrown if a modification of the array was detected.

set

public void set(int element)
Sets the element at which the iterator is currently pointing.

Parameters:
element - the value to set at the current position.
Throws:
ListModifiedException - thrown if a modification of the array was detected.