fr.univNantes.intcolls
Class ArrayLongListIterator

java.lang.Object
  extended by fr.univNantes.intcolls.ArrayLongListIterator
All Implemented Interfaces:
java.util.Iterator<java.lang.Long>, java.util.ListIterator<java.lang.Long>

public class ArrayLongListIterator
extends java.lang.Object
implements java.util.ListIterator<java.lang.Long>

Iterator implementation for ArrayLongList

Author:
Pierre-Olivier Terrisse.

Field Summary
private  int curIndex
          Current index
private  byte prevCall
          = 1 if previous call was nextLong(), = 2 if previous call previousLong(), = 0 else
private  ArrayLongList ref
          Referent list
 
Constructor Summary
ArrayLongListIterator(ArrayLongList ref)
          Constructor
 
Method Summary
 void add(java.lang.Long e)
          Inserts the specified element into the list.
 boolean hasNext()
          Returns true if this list iterator has more elements when traversing the list in the forward direction.
 boolean hasPrevious()
          Returns true if this list iterator has more elements when traversing the list in the reverse direction.
 java.lang.Long next()
          Returns the next element in the list.
 int nextIndex()
          Returns the index of the element that would be returned by a subsequent call to next.
 long nextLong()
          Returns the next element in the list.
 java.lang.Long previous()
          Returns the previous element in the list.
 int previousIndex()
          Returns the index of the element that would be returned by a subsequent call to previous.
 long previousLong()
          Returns the previous element in the list.
 void remove()
          Removes from the list the last element that was returned by next or previous
 void set(java.lang.Long e)
          Replaces the last element returned by next or previous with the specified element.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ref

private ArrayLongList ref
Referent list


curIndex

private int curIndex
Current index


prevCall

private byte prevCall
= 1 if previous call was nextLong(), = 2 if previous call previousLong(), = 0 else

Constructor Detail

ArrayLongListIterator

public ArrayLongListIterator(ArrayLongList ref)
Constructor

Parameters:
ref - referent list
Method Detail

hasNext

public boolean hasNext()
Returns true if this list iterator has more elements when traversing the list in the forward direction.

Specified by:
hasNext in interface java.util.Iterator<java.lang.Long>
Specified by:
hasNext in interface java.util.ListIterator<java.lang.Long>
Returns:
true if the list has more elements

nextLong

public long nextLong()
Returns the next element in the list.

Returns:
the next element
Throws:
java.util.NoSuchElementException - - if the iteration has no next element.

next

public java.lang.Long next()
Returns the next element in the list.

Specified by:
next in interface java.util.Iterator<java.lang.Long>
Specified by:
next in interface java.util.ListIterator<java.lang.Long>
Returns:
the next element
Throws:
java.util.NoSuchElementException - - if the iteration has no next element.

hasPrevious

public boolean hasPrevious()
Returns true if this list iterator has more elements when traversing the list in the reverse direction.

Specified by:
hasPrevious in interface java.util.ListIterator<java.lang.Long>
Returns:
previous element
Throws:
java.util.NoSuchElementException - - if the iteration has no previous element.

previousLong

public long previousLong()
Returns the previous element in the list.

Returns:
the previous element in the list.
Throws:
java.util.NoSuchElementException - - if the iteration has no previous element.

previous

public java.lang.Long previous()
Returns the previous element in the list.

Specified by:
previous in interface java.util.ListIterator<java.lang.Long>
Returns:
the previous element in the list.
Throws:
java.util.NoSuchElementException - - if the iteration has no previous element.

nextIndex

public int nextIndex()
Returns the index of the element that would be returned by a subsequent call to next.

Specified by:
nextIndex in interface java.util.ListIterator<java.lang.Long>
Returns:
the index of the element that would be returned by a subsequent call to next, or list size if list iterator is at end of list.

previousIndex

public int previousIndex()
Returns the index of the element that would be returned by a subsequent call to previous. (Returns -1 if the list iterator is at the beginning of the list.)

Specified by:
previousIndex in interface java.util.ListIterator<java.lang.Long>
Returns:
the index of the element that would be returned by a subsequent call to previous, or -1 if list iterator is at beginning of list.

remove

public void remove()
Removes from the list the last element that was returned by next or previous

Specified by:
remove in interface java.util.Iterator<java.lang.Long>
Specified by:
remove in interface java.util.ListIterator<java.lang.Long>
Throws:
java.lang.IllegalStateException - if neither next nor previous have been called, or remove or add have been called after the last call to next or previous.

set

public void set(java.lang.Long e)
Replaces the last element returned by next or previous with the specified element. This call can be made only if neither ListIterator.remove nor ListIterator.add have been called after the last call to next or previous.

Specified by:
set in interface java.util.ListIterator<java.lang.Long>
Parameters:
e - the element with which to replace the last element returned by next or previous.
Throws:
java.lang.IllegalStateException - - if neither next nor previous have been called, or remove or add have been called after the last call to next or previous.

add

public void add(java.lang.Long e)
Inserts the specified element into the list.

Specified by:
add in interface java.util.ListIterator<java.lang.Long>
Parameters:
e - the element to insert.