public class ListSequence<T> extends java.util.AbstractSequentialList<T> 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.Constructor and Description |
---|
ListSequence() |
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(int index) |
void |
clear() |
<U extends java.util.Collection<T>> |
collectInto(U collection)
Collect this
Sequence into the given Collection . |
static <T> ListSequence<T> |
concat(java.util.List<java.util.List<T>> lists) |
static <T> ListSequence<T> |
concat(java.util.List<T>... lists) |
boolean |
contains(java.lang.Object item) |
static <T> ListSequence<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> ListSequence<T> |
from(java.util.List<T> list) |
boolean |
isEmpty() |
java.util.Iterator<T> |
iterator() |
java.util.Optional<T> |
last() |
java.util.ListIterator<T> |
listIterator() |
java.util.ListIterator<T> |
listIterator(int index) |
<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> ListSequence<T> |
of(T... items)
Create a
Sequence with one item. |
static <T> ListSequence<T> |
of(T item)
Create a
Sequence with one item. |
Sequence<T> |
reverse() |
int |
size() |
java.util.Spliterator<T> |
spliterator() |
java.util.stream.Stream<T> |
stream() |
ListSequence<T> |
subList(int from,
int to) |
java.util.List<T> |
toList()
Collect the elements in this
Sequence into a List . |
static <T> ListSequence<T> |
withCapacity(int capacity) |
add, equals, hashCode, indexOf, lastIndexOf, removeRange
addAll, containsAll, remove, removeAll, retainAll, toArray, toArray, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
adjacentEntries, adjacentPairs, all, all, any, any, append, append, at, at, batch, batch, cache, cache, cache, chars, charsFrom, collect, collect, collectInto, concat, concat, containsAll, containsAll, containsAny, containsAny, delimit, delimit, distinct, endingAt, endingAt, endingAtNull, entries, excluding, excluding, filter, filterBack, filterBack, filterForward, filterForward, filterIndexed, first, first, first, flatten, flatten, forEachIndexed, from, from, generate, including, including, index, interleave, ints, intsFrom, intsFromZero, join, join, join, last, last, limit, longs, longsFrom, longsFromZero, mapBack, mapBack, mapForward, mapForward, mapIndexed, max, max, min, min, multiGenerate, none, none, once, once, pairs, peek, peekBack, peekBack, peekForward, peekForward, peekIndexed, prefix, range, range, range, recurse, recurse, reduce, reduce, repeat, repeat, shuffle, shuffle, shuffle, skip, skipTail, sorted, sorted, split, split, startingAfter, startingAfter, startingFrom, startingFrom, step, suffix, swap, toArray, toBiSequence, toChars, toCollection, toDoubles, toEntrySequence, toInts, toList, toLongs, toMap, toMap, toMap, toMap, toSet, toSet, toSortedMap, toSortedMap, toSortedSet, until, until, untilNull, window, window
add, addAll, containsAll, remove, removeAll, retainAll, toArray, toArray
public static <T> ListSequence<T> empty()
Sequence
Sequence
with no items.empty
in interface IterableCollection<T>
empty
in interface Sequence<T>
Sequence.of(Object)
,
Sequence.of(Object...)
,
Sequence.from(Iterable)
public static <T> ListSequence<T> of(T item)
Sequence
Sequence
with one item.of
in interface IterableCollection<T>
of
in interface Sequence<T>
Sequence.of(Object...)
,
Sequence.from(Iterable)
public static <T> ListSequence<T> of(T... items)
Sequence
Sequence
with one item.of
in interface IterableCollection<T>
of
in interface Sequence<T>
Sequence.of(Object...)
,
Sequence.from(Iterable)
public static <T> ListSequence<T> from(java.util.List<T> list)
@SafeVarargs public static <T> ListSequence<T> concat(java.util.List<T>... lists)
public static <T> ListSequence<T> concat(java.util.List<java.util.List<T>> lists)
public static <T> ListSequence<T> withCapacity(int capacity)
public java.util.Iterator<T> iterator()
public java.util.ListIterator<T> listIterator()
public java.util.ListIterator<T> listIterator(int index)
public java.util.Spliterator<T> spliterator()
spliterator
in interface java.lang.Iterable<T>
spliterator
in interface java.util.Collection<T>
spliterator
in interface java.util.List<T>
spliterator
in interface IterableCollection<T>
spliterator
in interface Sequence<T>
public ListSequence<T> subList(int from, int to)
public java.util.List<T> asList()
public java.util.List<T> toList()
Sequence
Sequence
into a List
.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()
public int size()
public java.util.stream.Stream<T> stream()
stream
in interface java.util.Collection<T>
public boolean isEmpty()
public boolean contains(java.lang.Object item)
public java.util.Optional<T> at(int 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(ObjIntFunction)
,
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)