public abstract class THashPrimitiveIterator extends Objectimplements TPrimitiveIterator
Note that iteration is fastest if you forego the calls to hasNext in favor of checking the size of the structure yourself and then call next() that many times:
Iterator i = collection.iterator();
for (int size = collection.size(); size-- > 0;) {
Object o = i.next();
}
You may, of course, use the hasNext(), next() idiom too if you aren't in a performance critical spot.
| Modifier and Type | Field and Description |
|---|---|
protected int |
_expectedSize
the number of elements this iterator believes are in the data structure it accesses.
|
protected TPrimitiveHash |
_hash
the data structure this iterator traverses
|
protected int |
_index
the index used for iteration.
|
| Constructor and Description |
|---|
THashPrimitiveIterator(TPrimitiveHash
Creates a
TPrimitiveIterator for the specified collection.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
hasNext()
Returns true if the iterator can be advanced past its current location.
|
protected void |
moveToNextIndex()
Sets the internal
index so that the `next' object can be returned.
|
protected int |
nextIndex()
Returns the index of the next value in the data structure or a negative value if the iterator is exhausted.
|
void |
remove()
Removes the last entry returned by the iterator.
|
protected final TPrimitiveHash_hash
protected int _expectedSize
protected int _index
public THashPrimitiveIterator(TPrimitiveHashhash)
hash - the
TPrimitiveHash we want to iterate over.
protected final int nextIndex()
int value
ConcurrentModificationException - if the underlying collection's size has been modified since the iterator was created.
public boolean hasNext()
hasNext in interface
TIterator
hasNext in interface
TPrimitiveIterator
boolean value
public void remove()
protected final void moveToNextIndex()