gnu.trove
Class TIterator

java.lang.Object
  extended by gnu.trove.TIterator
Direct Known Subclasses:
THashIterator, TObjectDoubleIterator, TObjectFloatIterator, TObjectIntIterator, TObjectLongIterator, TPrimitiveIterator

abstract class TIterator
extends java.lang.Object

Abstract iterator class for THash implementations. This class provides some of the common iterator operations (hasNext(), remove()) and allows subclasses to define the mechanism(s) for advancing the iterator and returning data.

Version:
$Id: TIterator.java,v 1.1 2002/09/22 21:53:42 ericdf Exp $
Author:
Eric D. Friedman

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
TIterator(THash hash)
          Create an instance of TIterator over the specified THash.
 
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.
protected abstract  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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_hash

protected final THash _hash
the data structure this iterator traverses


_expectedSize

protected int _expectedSize
the number of elements this iterator believes are in the data structure it accesses.


_index

protected int _index
the index used for iteration.

Constructor Detail

TIterator

public TIterator(THash hash)
Create an instance of TIterator over the specified THash.

Method Detail

hasNext

public boolean hasNext()
Returns true if the iterator can be advanced past its current location.

Returns:
a boolean value

remove

public void remove()
Removes the last entry returned by the iterator. Invoking this method more than once for a single entry will leave the underlying data structure in a confused state.


moveToNextIndex

protected final void moveToNextIndex()
Sets the internal index so that the `next' object can be returned.


nextIndex

protected abstract int nextIndex()
Returns the index of the next value in the data structure or a negative value if the iterator is exhausted.

Returns:
an int value