cz.cuni.amis.utils.iterators
Class CircularListIterator<E>

java.lang.Object
  extended by cz.cuni.amis.utils.iterators.CircularListIterator<E>
Type Parameters:
E - contents of the iterable
All Implemented Interfaces:
java.util.Iterator<E>, java.util.ListIterator<E>

public class CircularListIterator<E>
extends java.lang.Object
implements java.util.ListIterator<E>

Implements a circular iterator that iterates over any List instance instance. Useful for obtaining bidirectional ListIterator. Not fully tested!


Field Summary
protected  boolean moved
           
protected  boolean passedBeginning
           
protected  boolean passedEnd
           
 
Constructor Summary
CircularListIterator(CircularListIterator<E> source)
          Copy constructor for CircularListIterator.
CircularListIterator(java.util.List<E> toIterateOver)
          Constructs an instance of an CircularListIterator.
CircularListIterator(java.util.List<E> toIterateOver, int index)
          Constructs an instance of an CircularListIterator.
 
Method Summary
 void add(E e)
           
 int currentIndex()
           
protected  java.lang.Iterable<E> getIterable()
           
protected  java.util.Iterator<E> getIterator()
           
 boolean hasNext()
           
 boolean hasPassedBeginning()
           
 boolean hasPassedEnd()
           
 boolean hasPrevious()
           
 E next()
           
 int nextIndex()
           
 CircularListIterator<E> nextIter()
           
 E previous()
           
 int previousIndex()
           
 CircularListIterator<E> previousIter()
           
 void remove()
           
protected  void restartIteratorBeginning()
           
protected  void restartIteratorEnd()
           
 void set(E e)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

passedEnd

protected boolean passedEnd

passedBeginning

protected boolean passedBeginning

moved

protected boolean moved
Constructor Detail

CircularListIterator

public CircularListIterator(java.util.List<E> toIterateOver)
Constructs an instance of an CircularListIterator.

Parameters:
toIterateOver - List to be iterated over

CircularListIterator

public CircularListIterator(java.util.List<E> toIterateOver,
                            int index)
Constructs an instance of an CircularListIterator.

Parameters:
toIterateOver - List to be iterated over
index - an index to begin iteration at

CircularListIterator

public CircularListIterator(CircularListIterator<E> source)
Copy constructor for CircularListIterator.

Parameters:
source -
Method Detail

hasNext

public boolean hasNext()
Specified by:
hasNext in interface java.util.Iterator<E>
Specified by:
hasNext in interface java.util.ListIterator<E>

next

public E next()
Specified by:
next in interface java.util.Iterator<E>
Specified by:
next in interface java.util.ListIterator<E>

remove

public void remove()
Specified by:
remove in interface java.util.Iterator<E>
Specified by:
remove in interface java.util.ListIterator<E>

hasPassedEnd

public boolean hasPassedEnd()

hasPassedBeginning

public boolean hasPassedBeginning()

getIterable

protected java.lang.Iterable<E> getIterable()

getIterator

protected java.util.Iterator<E> getIterator()

restartIteratorBeginning

protected void restartIteratorBeginning()

restartIteratorEnd

protected void restartIteratorEnd()

add

public void add(E e)
Specified by:
add in interface java.util.ListIterator<E>

hasPrevious

public boolean hasPrevious()
Specified by:
hasPrevious in interface java.util.ListIterator<E>

nextIndex

public int nextIndex()
Specified by:
nextIndex in interface java.util.ListIterator<E>

previous

public E previous()
Specified by:
previous in interface java.util.ListIterator<E>

previousIndex

public int previousIndex()
Specified by:
previousIndex in interface java.util.ListIterator<E>

set

public void set(E e)
Specified by:
set in interface java.util.ListIterator<E>

currentIndex

public int currentIndex()

previousIter

public CircularListIterator<E> previousIter()

nextIter

public CircularListIterator<E> nextIter()