gnu.trove
Class TLinkedList.IteratorImpl

java.lang.Object
  extended by gnu.trove.TLinkedList.IteratorImpl
All Implemented Interfaces:
java.util.Iterator, java.util.ListIterator
Enclosing class:
TLinkedList

protected final class TLinkedList.IteratorImpl
extends java.lang.Object
implements java.util.ListIterator

A ListIterator that supports additions and deletions.


Field Summary
private  TLinkable _lastReturned
           
private  TLinkable _next
           
private  int _nextIndex
           
 
Constructor Summary
TLinkedList.IteratorImpl(int position)
          Creates a new Iterator instance positioned at index.
 
Method Summary
 void add(java.lang.Object linkable)
          Insert linkable at the current position of the iterator.
 boolean hasNext()
          True if a call to next() will return an object.
 boolean hasPrevious()
          True if a call to previous() will return a value.
 java.lang.Object next()
          Returns the value at the Iterator's index and advances the iterator.
 int nextIndex()
          returns the index of the next node in the list (the one that would be returned by a call to next()).
 java.lang.Object previous()
          Returns the value before the Iterator's index and moves the iterator back one index.
 int previousIndex()
          Returns the previous element's index.
 void remove()
          Removes the current element in the list and shrinks its size accordingly.
 void set(java.lang.Object linkable)
          Replaces the current element in the list with linkable
private  void swap(TLinkable from, TLinkable to)
          Replace from with to in the list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_nextIndex

private int _nextIndex

_next

private TLinkable _next

_lastReturned

private TLinkable _lastReturned
Constructor Detail

TLinkedList.IteratorImpl

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

Parameters:
position - an int value
Method Detail

add

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

Specified by:
add in interface java.util.ListIterator
Parameters:
linkable - an object of type TLinkable

hasNext

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

Specified by:
hasNext in interface java.util.Iterator
Specified by:
hasNext in interface java.util.ListIterator
Returns:
a boolean value

hasPrevious

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

Specified by:
hasPrevious in interface java.util.ListIterator
Returns:
a boolean value

next

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

Specified by:
next in interface java.util.Iterator
Specified by:
next in interface java.util.ListIterator
Returns:
an Object value
Throws:
java.util.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()).

Specified by:
nextIndex in interface java.util.ListIterator
Returns:
an int value

previous

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

Specified by:
previous in interface java.util.ListIterator
Returns:
an Object value
Throws:
java.util.NoSuchElementException - if there is no previous element.

previousIndex

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

Specified by:
previousIndex in interface java.util.ListIterator
Returns:
an int value

remove

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

Specified by:
remove in interface java.util.Iterator
Specified by:
remove in interface java.util.ListIterator
Throws:
java.lang.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(java.lang.Object linkable)
Replaces the current element in the list with linkable

Specified by:
set in interface java.util.ListIterator
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