|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.darwinsys.util.ArrayIterator
public class ArrayIterator
De-mystify the Iterator interface, showing how to write a simple Iterator for an Array of Objects.
Field Summary | |
---|---|
protected java.lang.Object[] |
data
The data to be iterated over. |
protected int |
index
|
Constructor Summary | |
---|---|
ArrayIterator(java.lang.Object[] d)
Construct an ArrayIterator object. |
Method Summary | |
---|---|
boolean |
hasNext()
Tell if there are any more elements. |
java.lang.Object |
next()
Returns the next element from the data |
void |
remove()
Remove the object that next() just returned. |
void |
setData(java.lang.Object[] d)
(Re)set the data array to the given array, and reset the iterator. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.lang.Object[] data
protected int index
Constructor Detail |
---|
public ArrayIterator(java.lang.Object[] d)
d
- The array of objects to be iterated over.Method Detail |
---|
public void setData(java.lang.Object[] d)
d
- The array of objects to be iterated over.public boolean hasNext()
hasNext
in interface java.util.Iterator
public java.lang.Object next()
next
in interface java.util.Iterator
public void remove()
remove
in interface java.util.Iterator
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |