|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectgnu.trove.impl.hash.THashIterator<V>
public abstract class THashIterator<V>
Implements all iterator functions for the hashed object set. Subclasses may override objectAtIndex to vary the object returned by calls to next() (e.g. for values, and Map.Entry objects).
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.
| Field Summary | |
|---|---|
protected int |
_expectedSize
the number of elements this iterator believes are in the data structure it accesses. |
protected THash |
_hash
the data structure this iterator traverses |
protected int |
_index
the index used for iteration. |
| Constructor Summary | |
|---|---|
protected |
THashIterator(TObjectHash<V> hash)
Create an instance of THashIterator over the values of the TObjectHash |
| Method Summary | |
|---|---|
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. |
V |
next()
Moves the iterator to the next Object and returns it. |
protected int |
nextIndex()
Returns the index of the next value in the data structure or a negative value if the iterator is exhausted. |
protected abstract V |
objectAtIndex(int index)
Returns the object at the specified index. |
void |
remove()
Removes the last entry returned by the iterator. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected final THash _hash
protected int _expectedSize
protected int _index
| Constructor Detail |
|---|
protected THashIterator(TObjectHash<V> hash)
hash - the object| Method Detail |
|---|
public boolean hasNext()
hasNext in interface TIteratorhasNext in interface java.util.Iterator<V>boolean valueprotected final void moveToNextIndex()
public V next()
next in interface java.util.Iterator<V>Object value
java.util.ConcurrentModificationException - if the structure was changed using a method that isn't on this
iterator.
java.util.NoSuchElementException - if this is called on an exhausted iterator.protected final int nextIndex()
int value
java.util.ConcurrentModificationException - if the underlying collection's size has been modified since the
iterator was created.protected abstract V objectAtIndex(int index)
index - the index of the value to return.
Object valuepublic void remove()
remove in interface TIteratorremove in interface java.util.Iterator<V>
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||