|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectau.com.zip.cs.UselessIterator
au.com.zip.cs.CounterIterator
public class CounterIterator
An Iterator that counts from zero to a bound.
Handy to subclass to iterate over arrays or Lists.
| Constructor Summary | |
|---|---|
CounterIterator(int size)
Construct a CounterIterator that counts from 0 to size-1. |
|
| Method Summary | |
|---|---|
protected void |
bump()
A hack to bump the iterator index by one. |
int |
getBound()
Return the bound of this CounterIterator. |
int |
getIndex()
Return the index of the last Object returned by next(). |
boolean |
hasNext()
|
Object |
next()
Return the next element. |
| Methods inherited from class au.com.zip.cs.UselessIterator |
|---|
remove |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public CounterIterator(int size)
size - the Iterator bound| Method Detail |
|---|
public int getBound()
public int getIndex()
next().
public boolean hasNext()
protected void bump()
next()
to avoid the wasted construction of an Integer.
// A next() that returns List elements. public Object next() bump(); return stateList.get(getIndex()); }
public Object next()
Integer.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||