org.javimmutable.collections.cursors
Class IterableCursor

java.lang.Object
  extended by org.javimmutable.collections.cursors.IterableCursor

@Immutable
public abstract class IterableCursor
extends Object

Provides objects implementing the Cursor interface that can be used to traverse an Iterable. The Cursors are not actually immutable but are designed to behave as though they are. However since they depend on a mutable object tied to a mutable collection for their state they are not thread safe. They should only be used when no other threads could be modifying the underlying collection. Also their next() methods can throw exceptions due to concurrent modification of the collection.


Constructor Summary
IterableCursor()
           
 
Method Summary
static
<T> Cursor<T>
of(Iterable<T> iterable)
          Creates a mutable Cursor implementation that traverses the specified iterable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IterableCursor

public IterableCursor()
Method Detail

of

public static <T> Cursor<T> of(Iterable<T> iterable)
Creates a mutable Cursor implementation that traverses the specified iterable. Note that because the Iterator and the collection it points to are not immutable outside factors can interfere with the operation of this class. In particular this class is not thread safe so the caller must take precautions to synchronize access to the underlying collection.

The Cursor retains information obtained from the Iterator so that multiple passes can be made over the data, intermediate Cursor values can be saved and resumed for look-ahead etc.

Type Parameters:
T -
Parameters:
iterable -
Returns:


Copyright © 2014 Burton Computer Corporation. All rights reserved.