public class CollectionSequence<T> extends java.lang.Object implements Sequence<T>
Sequence
backed by a Collection
. Implements certain operations on Sequence
in a more performant
way due to the Collection
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 |
---|
CollectionSequence() |
CollectionSequence(int capacity) |
Modifier and Type | Method and Description |
---|---|
boolean |
add(T t) |
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() |
void |
clear() |
<U extends java.util.Collection<T>> |
collectInto(U collection)
Collect this
Sequence into the given Collection . |
static <T> Sequence<T> |
concat(java.util.Collection<java.util.Collection<T>> collections) |
static <T> Sequence<T> |
concat(java.util.Collection<T>... collections) |
boolean |
contains(java.lang.Object 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.Collection<T> collection) |
boolean |
isEmpty() |
java.util.Iterator<T> |
iterator() |
<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. |
boolean |
remove(java.lang.Object o) |
int |
size() |
java.util.Spliterator<T> |
spliterator() |
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, 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, 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, reverse, 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
addAll, containsAll, removeAll, retainAll, toArray, toArray
public CollectionSequence()
public CollectionSequence(int capacity)
public static <T> Sequence<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> Sequence<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> Sequence<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> Sequence<T> from(java.util.Collection<T> collection)
public static <T> Sequence<T> concat(java.util.Collection<T>... collections)
public static <T> Sequence<T> concat(java.util.Collection<java.util.Collection<T>> collections)
public java.util.Iterator<T> iterator()
public java.util.Spliterator<T> spliterator()
spliterator
in interface java.lang.Iterable<T>
spliterator
in interface java.util.Collection<T>
spliterator
in interface IterableCollection<T>
spliterator
in interface Sequence<T>
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()
clear
in interface java.util.Collection<T>
clear
in interface IterableCollection<T>
public int size()
size
in interface java.util.Collection<T>
size
in interface IterableCollection<T>
public java.util.stream.Stream<T> stream()
stream
in interface java.util.Collection<T>
public boolean isEmpty()
isEmpty
in interface java.util.Collection<T>
isEmpty
in interface IterableCollection<T>
public boolean add(T t)
add
in interface java.util.Collection<T>
add
in interface IterableCollection<T>
public boolean remove(java.lang.Object o)
remove
in interface java.util.Collection<T>
remove
in interface IterableCollection<T>
public boolean contains(java.lang.Object item)
contains
in interface java.util.Collection<T>
contains
in interface IterableCollection<T>
public java.util.List<T> asList()
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)