gnu.trove

Class TLinkedList.IteratorImpl

protected final class TLinkedList.IteratorImpl extends Object implements ListIterator

A ListIterator that supports additions and deletions.
Field Summary
TLinkable_lastReturned
TLinkable_next
int_nextIndex
Constructor Summary
IteratorImpl(int position)
Creates a new Iterator instance positioned at index.
Method Summary
voidadd(Object linkable)
Insert linkable at the current position of the iterator.
booleanhasNext()
True if a call to next() will return an object.
booleanhasPrevious()
True if a call to previous() will return a value.
Objectnext()
Returns the value at the Iterator's index and advances the iterator.
intnextIndex()
returns the index of the next node in the list (the one that would be returned by a call to next()).
Objectprevious()
Returns the value before the Iterator's index and moves the iterator back one index.
intpreviousIndex()
Returns the previous element's index.
voidremove()
Removes the current element in the list and shrinks its size accordingly.
voidset(Object linkable)
Replaces the current element in the list with linkable
voidswap(TLinkable from, TLinkable to)
Replace from with to in the list.

Field Detail

_lastReturned

private TLinkable _lastReturned

_next

private TLinkable _next

_nextIndex

private int _nextIndex

Constructor Detail

IteratorImpl

IteratorImpl(int position)
Creates a new Iterator instance positioned at index.

Parameters: position an int value

Method Detail

add

public final void add(Object linkable)
Insert linkable at the current position of the iterator. Calling next() after add() will return the added object.

Parameters: linkable an object of type TLinkable

hasNext

public final boolean hasNext()
True if a call to next() will return an object.

Returns: a boolean value

hasPrevious

public final boolean hasPrevious()
True if a call to previous() will return a value.

Returns: a boolean value

next

public final Object next()
Returns the value at the Iterator's index and advances the iterator.

Returns: an Object value

Throws: NoSuchElementException if there is no next element

nextIndex

public final int nextIndex()
returns the index of the next node in the list (the one that would be returned by a call to next()).

Returns: an int value

previous

public final Object previous()
Returns the value before the Iterator's index and moves the iterator back one index.

Returns: an Object value

Throws: NoSuchElementException if there is no previous element.

previousIndex

public final int previousIndex()
Returns the previous element's index.

Returns: an int value

remove

public final void remove()
Removes the current element in the list and shrinks its size accordingly.

Throws: IllegalStateException neither next nor previous have been invoked, or remove or add have been invoked after the last invocation of next or previous.

set

public final void set(Object linkable)
Replaces the current element in the list with linkable

Parameters: linkable an object of type TLinkable

swap

private void swap(TLinkable from, TLinkable to)
Replace from with to in the list.

Parameters: from a TLinkable value to a TLinkable value