public class ListSequence<T> extends java.lang.Object implements Sequence<T>
Sequence
backed by a List
. Implements certain operations on Sequence
in a more performant
way due to the List
backing. This class should normally not be used directly as e.g.
Sequence.from(Iterable)
and other methods return this class directly where appropriate.Modifier and Type | Method and Description |
---|---|
Sequence<T> |
append(java.lang.Iterable<T> iterable)
Append the elements of the given
Iterable to the end of this Sequence . |
Sequence<T> |
append(T... items)
Append the given elements to the end of this
Sequence . |
java.util.List<T> |
asList() |
java.util.Optional<T> |
at(long index) |
void |
clear()
Remove all elements matched by this sequence using
Iterator.remove() . |
<U extends java.util.Collection<T>> |
collectInto(U collection)
Collect this
Sequence into the given Collection . |
static <T> Sequence<T> |
concat(java.util.List<java.util.List<T>> lists) |
static <T> Sequence<T> |
concat(java.util.List<T>... lists) |
boolean |
contains(T item) |
static <T> Sequence<T> |
empty()
Create an empty
Sequence with no items. |
Sequence<T> |
filter(java.util.function.Predicate<? super T> predicate)
Filter the elements in this
Sequence , keeping only the elements that match the given Predicate . |
static <T> Sequence<T> |
from(java.util.List<T> list) |
boolean |
isEmpty() |
java.util.Iterator<T> |
iterator() |
java.util.Optional<T> |
last() |
<U> Sequence<U> |
map(java.util.function.Function<? super T,? extends U> mapper)
Map the values in this
Sequence to another set of values specified by the given mapper function. |
static <T> Sequence<T> |
of(T... items)
Create a
Sequence with one item. |
static <T> Sequence<T> |
of(T item)
Create a
Sequence with one item. |
Sequence<T> |
reverse() |
long |
size() |
java.util.stream.Stream<T> |
stream() |
java.util.List<T> |
toList()
Collect the elements in this
Sequence into a List . |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
adjacentEntries, adjacentPairs, all, all, any, any, append, append, at, at, batch, batch, cache, cache, cache, chars, chars, charsFrom, collect, collect, collectInto, concat, concat, containsAll, containsAll, containsAny, containsAny, count, delimit, delimit, distinct, endingAt, endingAt, endingAtNull, entries, excluding, excluding, filter, filterBack, filterBack, filterForward, filterForward, filterIndexed, first, first, first, flatten, flatten, forEachIndexed, from, from, from, from, from, generate, get, including, including, index, interleave, ints, ints, intsFrom, intsFromZero, join, join, join, last, last, limit, longs, longs, longsFrom, longsFromZero, mapBack, mapBack, mapForward, mapForward, mapIndexed, max, max, min, min, multiGenerate, none, none, once, once, pairs, partition, peek, peekBack, peekBack, peekForward, peekForward, peekIndexed, prefix, range, range, range, recurse, recurse, reduce, reduce, removeAll, repeat, repeat, second, second, second, shuffle, shuffle, shuffle, skip, skipTail, sorted, sorted, split, split, startingAfter, startingAfter, startingFrom, startingFrom, step, suffix, swap, third, third, third, toArray, toArray, toBiSequence, toChars, toCollection, toDoubles, toEntrySequence, toInts, toList, toLongs, toMap, toMap, toMap, toMap, toSet, toSet, toSortedMap, toSortedMap, toSortedSet, until, until, untilNull, window, window
public static <T> Sequence<T> empty()
Sequence
Sequence
with no items.empty
in interface Sequence<T>
Sequence.of(Object)
,
Sequence.of(Object...)
,
Sequence.from(Iterable)
public static <T> Sequence<T> of(T item)
Sequence
Sequence
with one item.of
in interface Sequence<T>
Sequence.of(Object...)
,
Sequence.from(Iterable)
public static <T> Sequence<T> of(T... items)
Sequence
Sequence
with one item.of
in interface Sequence<T>
Sequence.of(Object...)
,
Sequence.from(Iterable)
public static <T> Sequence<T> from(java.util.List<T> list)
public static <T> Sequence<T> concat(java.util.List<T>... lists)
public static <T> Sequence<T> concat(java.util.List<java.util.List<T>> lists)
public java.util.Iterator<T> iterator()
iterator
in interface java.lang.Iterable<T>
public java.util.List<T> toList()
Sequence
Sequence
into a List
.public java.util.List<T> asList()
public <U extends java.util.Collection<T>> U collectInto(U collection)
Sequence
Sequence
into the given Collection
.collectInto
in interface Sequence<T>
public void clear()
Sequence
Iterator.remove()
.public long size()
public java.util.stream.Stream<T> stream()
public boolean isEmpty()
public boolean contains(T item)
public java.util.Optional<T> at(long index)
public java.util.Optional<T> last()
public Sequence<T> filter(java.util.function.Predicate<? super T> predicate)
Sequence
Sequence
, keeping only the elements that match the given Predicate
.public <U> Sequence<U> map(java.util.function.Function<? super T,? extends U> mapper)
Sequence
Sequence
to another set of values specified by the given mapper
function.map
in interface Sequence<T>
Sequence.mapIndexed(ObjLongFunction)
,
Sequence.mapBack(BiFunction)
,
Sequence.mapForward(BiFunction)
,
Sequence.flatten()
,
Sequence.flatten(Function)
,
Sequence.toChars(ToCharFunction)
,
Sequence.toInts(ToIntFunction)
,
Sequence.toLongs(ToLongFunction)
,
Sequence.toDoubles(ToDoubleFunction)
public Sequence<T> append(java.lang.Iterable<T> iterable)
Sequence
Iterable
to the end of this Sequence
.append
in interface Sequence<T>
Sequence.cache(Iterable)