|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--structure.AbstractIterator | +--structure.VectorIterator
A private class for implementing an iterator over a Vector.
Typical usage:
import structure.Vector; import java.util.Iterator; public static void main(String[] args) { Vector argVec = new Vector(); for (int i = 0; i < args.length; i++) { argVec.addElement(args[i]); } Iterator it = argVec.iterator(); while (it.hasNext()) { System.out.println(it.next()); } }
Field Summary | |
protected int |
current
The index of the current value. |
protected Vector |
theVector
The associated vector |
Constructor Summary | |
VectorIterator(Vector v)
Construct a vector iterator to traverse vector v |
Method Summary | |
java.lang.Object |
get()
Fetch a reference to the current value. |
boolean |
hasNext()
Determine if some of the elements have yet to be considered. |
java.lang.Object |
next()
Return current value, and increment iterator. |
void |
reset()
Reset the vector iterator to the first value in the vector. |
Methods inherited from class structure.AbstractIterator |
hasMoreElements, nextElement, remove, value |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected Vector theVector
protected int current
Constructor Detail |
public VectorIterator(Vector v)
v
- The underlying vector.Method Detail |
public void reset()
reset
in class AbstractIterator
public boolean hasNext()
hasNext
in interface java.util.Iterator
hasNext
in class AbstractIterator
AbstractIterator.hasMoreElements()
public java.lang.Object get()
get
in class AbstractIterator
public java.lang.Object next()
next
in interface java.util.Iterator
next
in class AbstractIterator
AbstractIterator.hasMoreElements()
,
AbstractIterator.value()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |