org.javimmutable.collections.common
Class IteratorAdaptor<T>

java.lang.Object
  extended by org.javimmutable.collections.common.IteratorAdaptor<T>
Type Parameters:
T -
All Implemented Interfaces:
Iterator<T>

public class IteratorAdaptor<T>
extends Object
implements Iterator<T>

Adaptor to traverse a Cursor using the Iterator API. Evaluation of the Cursor is lazy in the sense that Cursor.next() is not called for the first time until the hasNext() method is called. The next() method automatically calls the Cursor's next() method after obtaining the current value to return as its result. In this way the protocol matches how Iterators behave.


Constructor Summary
IteratorAdaptor(Cursor<T> cursor)
           
 
Method Summary
 boolean hasNext()
           
 T next()
           
static
<V> IteratorAdaptor<V>
of(Cursor<V> cursor)
           
 void remove()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IteratorAdaptor

public IteratorAdaptor(Cursor<T> cursor)
Method Detail

of

public static <V> IteratorAdaptor<V> of(Cursor<V> cursor)

hasNext

public boolean hasNext()
Specified by:
hasNext in interface Iterator<T>

next

public T next()
Specified by:
next in interface Iterator<T>

remove

public void remove()
Specified by:
remove in interface Iterator<T>


Copyright © 2014 Burton Computer Corporation. All rights reserved.