net.sf.jga.util

Class SingletonIterator<T>

public class SingletonIterator<T> extends Object implements ListIterator<T>

Iterates over a single item. The iterator is structured as a list iterator, but the list is a fixed size (1). The value may be changed after it has been retrieved at least one time.

Author: David A. Hall

Constructor Summary
SingletonIterator(T value)
Method Summary
voidadd(T arg)
booleanhasNext()
Returns true if the item has not yet been returned.
booleanhasPrevious()
Returns true if the item has not yet been returned.
Tnext()
Returns the single item
intnextIndex()
Tprevious()
Returns the single item
intpreviousIndex()
voidremove()
voidset(T value)

Constructor Detail

SingletonIterator

public SingletonIterator(T value)

Method Detail

add

public void add(T arg)

hasNext

public boolean hasNext()
Returns true if the item has not yet been returned.

Returns: true if the item has not yet been returned

hasPrevious

public boolean hasPrevious()
Returns true if the item has not yet been returned.

Returns: true if the item has not yet been returned

next

public T next()
Returns the single item

Returns: the single item

Throws: NoSuchElementException if the item has already been returned

nextIndex

public int nextIndex()

previous

public T previous()
Returns the single item

Returns: the single item

Throws: NoSuchElementException if the item has already been returned

previousIndex

public int previousIndex()

remove

public void remove()

set

public void set(T value)