org.rutil.collection
Class AbstractIterator<E>

java.lang.Object
  extended by org.rutil.collection.AbstractIterator<E>
All Implemented Interfaces:
java.util.Iterator<E>
Direct Known Subclasses:
AbstractListIterator

public abstract class AbstractIterator<E>
extends java.lang.Object
implements java.util.Iterator<E>

Iterator implementation that is backed by an indexed data structure. The following methods have to implemented for a read-only implemenation.

size()

E get(index)

by default, remove() method throws and unsupported operation exception.

Author:
mohan

Field Summary
protected  int curIndex
           
 
Constructor Summary
AbstractIterator()
           
AbstractIterator(int curIndex)
           
 
Method Summary
protected abstract  E get(int index)
           
 boolean hasNext()
           
 E next()
           
 void remove()
           
protected abstract  int size()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

curIndex

protected int curIndex
Constructor Detail

AbstractIterator

public AbstractIterator()

AbstractIterator

public AbstractIterator(int curIndex)
Method Detail

hasNext

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

next

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

remove

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

size

protected abstract int size()

get

protected abstract E get(int index)