nom.tam.util
Class HashedList.HashedListIterator

java.lang.Object
  extended by nom.tam.util.HashedList.HashedListIterator
All Implemented Interfaces:
java.util.Iterator, Cursor
Enclosing class:
HashedList

public class HashedList.HashedListIterator
extends java.lang.Object
implements Cursor

This inner class defines an iterator over the hashed list. An iterator need not start at the beginning of the list.

This class can be used by external users to both add and delete elements from the list. It implements the standard Iterator interface but also provides methods to add keyed or unkeyed elements at the current location.

Users may move either direction in the list using the next and prev calls. Note that a call to prev followed by a call to next (or vice versa) will return the same element twice.

The class is implemented as an inner class so that it can easily access the state of the associated HashedList.


Method Summary
 void add(java.lang.Object ref)
          Add an entry at the current location.
 void add(java.lang.Object key, java.lang.Object ref)
          Add a keyed entry at the current location.
 boolean hasNext()
          Is there another element?
 boolean hasPrev()
          Is there a previous element?
 java.lang.Object next()
          Get the next entry.
 java.lang.Object prev()
          Get the previous entry.
 void remove()
          Remove the last retrieved entry.
 void setKey(java.lang.Object key)
          Point the iterator to a particular keyed entry.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

hasNext

public boolean hasNext()
Is there another element?

Specified by:
hasNext in interface java.util.Iterator

hasPrev

public boolean hasPrev()
Is there a previous element?

Specified by:
hasPrev in interface Cursor

next

public java.lang.Object next()
                      throws java.util.NoSuchElementException
Get the next entry.

Specified by:
next in interface java.util.Iterator
Throws:
java.util.NoSuchElementException

prev

public java.lang.Object prev()
                      throws java.util.NoSuchElementException
Get the previous entry.

Specified by:
prev in interface Cursor
Throws:
java.util.NoSuchElementException

remove

public void remove()
Remove the last retrieved entry. Note that remove can be called only after a call to next, and only once per such call. Remove cannot be called after a call to prev.

Specified by:
remove in interface java.util.Iterator

add

public void add(java.lang.Object ref)
Add an entry at the current location. The new entry goes before the entry that would be returned in the next 'next' call, and that call will not be affected by the insertion. Note: this method is not in the Iterator interface.

Specified by:
add in interface Cursor

add

public void add(java.lang.Object key,
                java.lang.Object ref)
Add a keyed entry at the current location. The new entry is inserted before the entry that would be returned in the next invocation of 'next'. The return value for that call is unaffected. Note: this method is not in the Iterator interface.

Specified by:
add in interface Cursor

setKey

public void setKey(java.lang.Object key)
Point the iterator to a particular keyed entry. This method is not in the Iterator interface.

Specified by:
setKey in interface Cursor
Parameters:
key -