edu.rice.cs.plt.iter
Class ReadOnceIterable<T>

java.lang.Object
  extended by edu.rice.cs.plt.iter.ReadOnceIterable<T>
All Implemented Interfaces:
java.lang.Iterable<T>

public class ReadOnceIterable<T>
extends java.lang.Object
implements java.lang.Iterable<T>

An iterable that simply wraps an Iterator. Unlike most iterables, state changes on the wrapped iterator (such as advancing) are reflected across invocations of iterator(); once the iterator has been traversed, this iterable is effectively empty. While these semantics are inconvenient at times, they also allow a very lightweight implementation. Clients that need to traverse an iterator multiple times (or that need a SizedIterable) can use a SnapshotIterable instead, at the expense of copying and storing the entire contents of the iterator.


Constructor Summary
ReadOnceIterable(java.util.Iterator<T> iter)
           
 
Method Summary
 java.util.Iterator<T> iterator()
           
static
<T> ReadOnceIterable<T>
make(java.util.Iterator<T> iter)
          Call the constructor (allows T to be inferred)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReadOnceIterable

public ReadOnceIterable(java.util.Iterator<T> iter)
Method Detail

iterator

public java.util.Iterator<T> iterator()
Specified by:
iterator in interface java.lang.Iterable<T>

make

public static <T> ReadOnceIterable<T> make(java.util.Iterator<T> iter)
Call the constructor (allows T to be inferred)