structure
Class ChainedHashtableIterator
java.lang.Object
|
+--structure.AbstractIterator
|
+--structure.ChainedHashtableIterator
- All Implemented Interfaces:
- Enumeration, Iterator
- class ChainedHashtableIterator
- extends AbstractIterator
A traversal of all the elements as they appear in a chained hashtable.
No order is guaranteed. This iterator is not publically accessable
and is used to implement ChainedHashtable's key and value iterators.
This iteration returns objects that are instances of Association
.
Typical use:
ChainedHashtable h = new ChainedHashtable();
// ...hashtable gets built up...
Iterator hi = new ChainedHashtableIterator(h.data)
;
while (hi.hasNext()
)
{
System.out.println(ai.next()
);
}
Field Summary |
protected List |
data
The list of values within the table. |
protected Iterator |
elements
The iterator over the elements of the list. |
Method Summary |
Object |
get()
Get current value of iterator. |
boolean |
hasNext()
Returns true iff there are unconsidered elements within the table. |
Object |
next()
Returns current value and increments iterator. |
void |
reset()
Resets the iterator to point to the beginning of the chained table. |
Methods inherited from class java.lang.Object |
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait |
data
protected List data
- The list of values within the table.
elements
protected Iterator elements
- The iterator over the elements of the list.
ChainedHashtableIterator
public ChainedHashtableIterator(List[] table)
- Construct an iterator over a chained hashtable.
- Parameters:
table
- The array of lists to be traversed.
reset
public void reset()
- Resets the iterator to point to the beginning of the chained table.
- Overrides:
reset
in class AbstractIterator
- Postcondition:
- resets iterator to beginning of hash table
hasNext
public boolean hasNext()
- Returns true iff there are unconsidered elements within the table.
- Overrides:
hasNext
in class AbstractIterator
- Postcondition:
- returns true if there are unvisited elements
- Returns:
- True iff there are elements yet to be considered within table.
next
public Object next()
- Returns current value and increments iterator.
- Overrides:
next
in class AbstractIterator
- Precondition:
- hasNext()
- Postcondition:
- returns current element, increments iterator
- Returns:
- The current value, before incrementing.
get
public Object get()
- Get current value of iterator.
- Overrides:
get
in class AbstractIterator
- Postcondition:
- returns current element
- Returns:
- The current value.