public final class Cursors extends Object
Compatibility: Public
Modifier and Type | Method and Description |
---|---|
static <T> Cursor<T> |
empty()
Create an empty cursor.
|
static <T> Cursor<T> |
filter(Cursor<?> cursor,
Class<T> type)
Filter a cursor to only contain elements of type type.
|
static <T> Cursor<T> |
filter(Cursor<T> cursor,
Predicate<? super T> predicate)
Filter a cursor.
|
static <T> ArrayList<T> |
makeList(Cursor<? extends T> cursor)
Read a cursor into a list, closing when it is finished.
|
static LongArrayList |
makeList(LongCursor cursor)
Read a LongCursor into a LongArrayList, closing the cursor when done.
|
static LongCursor |
makeLongCursor(Cursor<Long> cursor)
Make a fast long cursor.
|
static LongSet |
makeSet(LongCursor cursor)
Read a LongCursor into a LongSet, closing the cursor when done.
|
static <T> Cursor<T> |
sort(Cursor<T> cursor,
Comparator<? super T> comp)
Sort a cursor.
|
static <S,T> Cursor<T> |
transform(Cursor<S> cursor,
Function<? super S,? extends T> function)
Transform a cursor's values.
|
static <T> Cursor<T> |
wrap(Collection<? extends T> collection)
Wrap a collection in a cursor.
|
static <T> Cursor<T> |
wrap(Iterator<? extends T> iterator)
Wrap an iterator in a cursor.
|
static LongCursor |
wrap(LongCollection collection)
Construct a cursor over a collection.
|
static LongCursor |
wrap(LongIterator iter)
Wrap a long iterator in a cursor.
|
public static <T> Cursor<T> wrap(Iterator<? extends T> iterator)
T
- The type of data to return.iterator
- An iterator to wrappublic static <T> Cursor<T> wrap(Collection<? extends T> collection)
T
- The type of data to return.collection
- A collection to wrappublic static <T> Cursor<T> filter(@WillCloseWhenClosed Cursor<T> cursor, Predicate<? super T> predicate)
T
- The type of cursor rows.cursor
- The source cursor.predicate
- A predicate indicating which rows to return.true
.public static <T> Cursor<T> filter(@WillCloseWhenClosed Cursor<?> cursor, Class<T> type)
filter(Cursor, Predicate)
with a predicate from
Predicates.instanceOf(Class)
, this method also transforms the
cursor to be of the target type.T
- The type of value in the cursor.cursor
- The source cursor.type
- The type to filter.public static <S,T> Cursor<T> transform(@WillCloseWhenClosed Cursor<S> cursor, Function<? super S,? extends T> function)
S
- The type of source cursor rowsT
- The type of output cursor rowscursor
- The source cursorfunction
- A function to apply to each row in the cursor.public static <T> Cursor<T> empty()
T
- The type of value in the cursor.public static <T> ArrayList<T> makeList(@WillClose Cursor<? extends T> cursor)
T
- The type of item in the cursor.cursor
- The cursor.Cursor.getRowCount()
if possible,
but has not been trimmed.public static LongArrayList makeList(@WillClose LongCursor cursor)
cursor
- The LongCursor to be read into a list.Cursor.getRowCount()
if possible,
but has not been trimmed.public static LongSet makeSet(@WillClose LongCursor cursor)
cursor
- The LongCursor to be read into a set.public static LongCursor wrap(LongIterator iter)
iter
- An iterator.iter
. Closing the cursor is a no-op.public static LongCursor wrap(LongCollection collection)
collection
- A collection.public static LongCursor makeLongCursor(@WillCloseWhenClosed Cursor<Long> cursor)
cursor
- A cursor.LongCursor
. If cursor
is a LongCursor, it is returned.public static <T> Cursor<T> sort(@WillClose Cursor<T> cursor, Comparator<? super T> comp)
T
- The type of value in the cursor.cursor
- The cursor to sort.comp
- The comparator to use to sort the cursor.Copyright © 2013 GroupLens Research. All Rights Reserved.