|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.javimmutable.collections.cursors.StandardCursor
@Immutable public abstract class StandardCursor
Utility class that implements standard Cursor behavior for classes that do not naturally start at a position before the first element. Such classes can pass a Source implementation to the of() method and this class will ensure that traversal does not start until the next() method is called and does not progress beyond the point where atEnd() is true.
Nested Class Summary | |
---|---|
static interface |
StandardCursor.Source<T>
Simple interface for classes that can iterate immediately (i.e. |
Constructor Summary | |
---|---|
StandardCursor()
|
Method Summary | ||
---|---|---|
static Cursor<Integer> |
forRange(int low,
int high)
Creates a Cursor over a range of integers. |
|
static
|
iterator(StandardCursor.Source<T> source)
Creates a java.util.Iterator that iterates over values in the specified Source. |
|
static
|
makeList(Cursor<T> cursor)
Utility method, useful in unit tests, that collects all of the values in the Cursor into a List and returns the List. |
|
static
|
of()
Creates an empty cursor that has no values. |
|
static
|
of(Indexed<T> source)
Creates a Cursor for the given Indexed. |
|
static
|
of(StandardCursor.Source<T> source)
Creates a Cursor for the given Source. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public StandardCursor()
Method Detail |
---|
public static <T> Cursor<T> of()
T
-
public static <T> Cursor<T> of(StandardCursor.Source<T> source)
T
- source
-
public static <T> Cursor<T> of(Indexed<T> source)
T
- source
-
public static <T> Iterator<T> iterator(StandardCursor.Source<T> source)
T
- source
-
public static Cursor<Integer> forRange(int low, int high)
low
- high
-
public static <T> List<T> makeList(Cursor<T> cursor)
T
- cursor
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |