structure
Class HashtableIterator

java.lang.Object
  |
  +--structure.AbstractIterator
        |
        +--structure.HashtableIterator
All Implemented Interfaces:
java.util.Enumeration, java.util.Iterator

class HashtableIterator
extends AbstractIterator

A traversal of all the elements as they appear in a hashtable. No order is guaranteed. This iterator is not publically accessable and is used to implement Hashtable's key and value iterators. This iteration returns objects that are instances of Association.

Typical use:

      Hashtable h = new Hashtable();
      // ...hashtable gets built up...
      Iterator hi = new HashtableIterator(h.data);
      while (hi.hasNext())
      {
          System.out.println(ai.next());
      }
 


Field Summary
protected  int current
          The current entry being considered.
protected  Association[] data
          Reference to hash table data
 
Constructor Summary
HashtableIterator(Association[] table)
          Construct a traversal over a hashtable.
 
Method Summary
 java.lang.Object get()
          Get current value of traversal.
 boolean hasNext()
          Returns true iff there are unconsidered elements within the table.
 java.lang.Object next()
          Returns current value and increments traversal.
 void reset()
          Resets the traversal to point to the beginning of the table.
 
Methods inherited from class structure.AbstractIterator
hasMoreElements, nextElement, remove, value
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

current

protected int current
The current entry being considered.


data

protected Association[] data
Reference to hash table data

Constructor Detail

HashtableIterator

public HashtableIterator(Association[] table)
Construct a traversal over a hashtable.

Parameters:
table - The array of lists to be traversed.
Method Detail

reset

public void reset()
Resets the traversal to point to the beginning of the table.

Specified by:
reset in class AbstractIterator

hasNext

public boolean hasNext()
Returns true iff there are unconsidered elements within the table.

Specified by:
hasNext in interface java.util.Iterator
Specified by:
hasNext in class AbstractIterator
Returns:
True iff there are elements yet to be considered within table.
See Also:
AbstractIterator.hasMoreElements()

next

public java.lang.Object next()
Returns current value and increments traversal.

Specified by:
next in interface java.util.Iterator
Specified by:
next in class AbstractIterator
Returns:
The current value, before incrementing.
See Also:
AbstractIterator.hasMoreElements(), AbstractIterator.value()

get

public java.lang.Object get()
Get current value of traversal.

Specified by:
get in class AbstractIterator
Returns:
The current value.