fr.univNantes.intcolls
Class ArrayIntListIterator

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

public class ArrayIntListIterator
extends java.lang.Object
implements java.util.ListIterator<java.lang.Integer>

Iterator implementation of ArrayIntList

Author:
Pierre-Olivier Terrisse.

Field Summary
private  int curIndex
          Current index
private  byte prevCall
          = 1 if previous call was nextInt(), = 2 if previous call previousInt(), = 0 else
private  ArrayIntList ref
          Referent list
 
Constructor Summary
ArrayIntListIterator(ArrayIntList ref)
          Constructor
 
Method Summary
 void add(java.lang.Integer 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.Integer 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.
 int nextInt()
          Returns the next element in the list.
 java.lang.Integer 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.
 int previousInt()
          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.Integer 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 ArrayIntList ref
Referent list


curIndex

private int curIndex
Current index


prevCall

private byte prevCall
= 1 if previous call was nextInt(), = 2 if previous call previousInt(), = 0 else

Constructor Detail

ArrayIntListIterator

public ArrayIntListIterator(ArrayIntList 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.Integer>
Specified by:
hasNext in interface java.util.ListIterator<java.lang.Integer>
Returns:
true if the list has more elements

nextInt

public int nextInt()
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.Integer next()
Returns the next element in the list.

Specified by:
next in interface java.util.Iterator<java.lang.Integer>
Specified by:
next in interface java.util.ListIterator<java.lang.Integer>
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.Integer>
Returns:
previous element
Throws:
java.util.NoSuchElementException - - if the iteration has no previous element.

previousInt

public int previousInt()
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.Integer previous()
Returns the previous element in the list.

Specified by:
previous in interface java.util.ListIterator<java.lang.Integer>
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.Integer>
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.Integer>
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.Integer>
Specified by:
remove in interface java.util.ListIterator<java.lang.Integer>
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.Integer 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.Integer>
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.Integer e)
Inserts the specified element into the list.

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