structure
Class ArrayIterator
java.lang.Object
structure.AbstractIterator
structure.ArrayIterator
- All Implemented Interfaces:
- java.util.Enumeration, java.util.Iterator
public class ArrayIterator
- extends AbstractIterator
Method Summary |
java.lang.Object |
get()
Returns the value currently being considered by the AbstractIterator. |
boolean |
hasNext()
Returns true if the iterator has more elements to visit. |
java.lang.Object |
next()
Moves, bumps, or "increments" the iterator along the traversal;
returns the next value considered. |
void |
reset()
Reset iterator to the beginning of the structure. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
data
protected java.lang.Object[] data
head
protected int head
count
protected int count
current
protected int current
remaining
protected int remaining
ArrayIterator
public ArrayIterator(java.lang.Object[] source)
ArrayIterator
public ArrayIterator(java.lang.Object[] source,
int first,
int size)
reset
public void reset()
- Description copied from class:
AbstractIterator
- Reset iterator to the beginning of the structure.
This method is not required of
Iterator
or
Enumeration
implementation, but some traversals
may allow efficient multi-pass implementations with little
overhead. The user is encouraged to implement this method.
- Specified by:
reset
in class AbstractIterator
hasNext
public boolean hasNext()
- Description copied from class:
AbstractIterator
- Returns true if the iterator has more elements to visit.
The method
hasMoreElements
is an
Enumeration
-required call to this method. The user
should override only this method.
- Specified by:
hasNext
in interface java.util.Iterator
- Specified by:
hasNext
in class AbstractIterator
- Returns:
- true iff the iterator has more elements to visit
- See Also:
AbstractIterator.hasMoreElements()
next
public java.lang.Object next()
- Description copied from class:
AbstractIterator
- Moves, bumps, or "increments" the iterator along the traversal;
returns the next value considered.
This method should only be called if the iterator has a next value.
To get a value from an iterator multiple times, use the
value
method.
This method is preferred over the nextElement
method.
- Specified by:
next
in interface java.util.Iterator
- Specified by:
next
in class AbstractIterator
- Returns:
- the current value
- See Also:
AbstractIterator.hasMoreElements()
,
AbstractIterator.value()
get
public java.lang.Object get()
- Description copied from class:
AbstractIterator
- Returns the value currently being considered by the AbstractIterator.
This method is required by neither
Iterator
nor
Enumeration
. This method should be implemented,
however, to provide better support for for
-loops.
- Specified by:
get
in class AbstractIterator
- Returns:
- the next value to be considered in iterator