@FunctionalInterface public interface CharSeq extends CharIterable
Iterable sequence of char values with Stream-like operations for refining,
transforming and collating the list of characters.| Modifier and Type | Method and Description |
|---|---|
static CharSeq |
all()
A
Sequence of all the Character values starting at Character.MIN_VALUE and ending at
Character.MAX_VALUE. |
default boolean |
all(CharPredicate predicate) |
default boolean |
any(CharPredicate predicate) |
default CharSeq |
append(char... characters)
Append the given
chars to the end of this CharSeq. |
default CharSeq |
append(CharIterable that)
|
default CharSeq |
append(CharIterator iterator)
|
default CharSeq |
append(java.util.stream.IntStream stream)
Append the
char values of the ints in the given IntStream to the end of this
CharSeq. |
default CharSeq |
append(java.lang.Iterable<java.lang.Character> iterable)
Append the
Characters in the given Iterable to the end of this CharSeq. |
default CharSeq |
append(java.util.Iterator<java.lang.Character> iterator)
Append the
Characters in the given Iterator to the end of this CharSeq. |
default CharSeq |
append(java.util.stream.Stream<java.lang.Character> stream)
Append the
Characters in the given Stream to the end of this CharSeq. |
default java.lang.String |
asString() |
default Sequence<CharSeq> |
batch(CharBiPredicate predicate)
Batch the elements of this
Sequence into a sequence of CharSeqs of distinct elements, where the
given predicate determines where to split the lists of partitioned elements. |
default Sequence<CharSeq> |
batch(int size)
Batch the elements of this
Sequence into a sequence of CharSeqs of distinct elements, each with
the given batch size. |
default Sequence<java.lang.Character> |
box()
Map the
chars in this CharSeq to their boxed Character counterparts. |
default <C> C |
collect(java.util.function.Supplier<? extends C> constructor,
ObjCharConsumer<? super C> adder)
Collect this
CharSeq into an arbitrary container using the given constructor and adder. |
default <C> C |
collectInto(C result,
ObjCharConsumer<? super C> adder)
Collect this
CharSeq into the given container using the given adder. |
default long |
count() |
default CharSeq |
distinct() |
static CharSeq |
empty()
Create an empty
CharSeq with no characters. |
default CharSeq |
endingAt(char terminal)
Terminate this
CharSeq sequence at the given element, including it as the last element in this CharSeq sequence. |
default CharSeq |
endingAt(CharPredicate terminal)
Terminate this
CharSeq sequence at the element that satisfies the given predicate, including the
element as the last element in this CharSeq sequence. |
default CharSeq |
filter(CharPredicate predicate)
Filter the elements in this
CharSeq, keeping only the elements that match the given
CharPredicate. |
default CharSeq |
filterBack(char firstPrevious,
CharBiPredicate predicate)
Filter this
CharSeq to another sequence of chars while peeking at the previous value in the
sequence. |
default CharSeq |
filterForward(char lastNext,
CharBiPredicate predicate)
Filter this
CharSeq to another sequence of chars while peeking at the next int in the sequence. |
default OptionalChar |
first() |
static CharSeq |
from(CharIterable iterable)
Create a
CharSeq from a CharIterable. |
static CharSeq |
from(CharIterator iterator)
Create a
CharSeq from a CharIterator of character values. |
static CharSeq |
from(java.lang.CharSequence csq)
Create a
CharSeq from a CharSequence. |
static CharSeq |
from(java.lang.Iterable<java.lang.Character> iterable)
Create a
CharSeq from an Iterable of Character values. |
static CharSeq |
from(java.util.Iterator<java.lang.Character> iterator)
Create a
CharSeq from an Iterator of Character values. |
static CharSeq |
from(java.util.stream.Stream<java.lang.Character> stream)
Create a
Sequence from a Stream of items. |
static CharSeq |
from(java.util.function.Supplier<? extends CharIterator> iteratorSupplier)
Create a
Sequence from Iterators of items supplied by the given Supplier. |
static CharSeq |
generate(CharSupplier supplier) |
default CharSeq |
interleave(CharSeq that)
Interleave the elements in this
CharSeq with those of the given CharSeq, stopping when either
sequence finishes. |
default java.lang.String |
join(java.lang.String delimiter)
Join this
CharSeq into a string separated by the given delimiter. |
default java.lang.String |
join(java.lang.String prefix,
java.lang.String delimiter,
java.lang.String suffix)
Join this
CharSeq into a string separated by the given delimiter, with the given prefix and suffix. |
default OptionalChar |
last() |
default CharSeq |
limit(long limit)
Limit the maximum number of
chars returned by this CharSeq. |
default CharSeq |
map(CharUnaryOperator mapper)
Map the
chars in this CharSeq to another set of chars specified by the given
mapper function. |
default CharSeq |
mapBack(char firstPrevious,
CharBinaryOperator mapper)
Map this
CharSeq to another sequence of characters while peeking at the previous character in the
sequence. |
default CharSeq |
mapForward(char lastNext,
CharBinaryOperator mapper)
Map this
CharSeq to another sequence of characters while peeking at the next character in the sequence. |
default OptionalChar |
max() |
default OptionalChar |
min() |
default boolean |
none(CharPredicate predicate) |
static CharSeq |
of(char... cs)
Create a
CharSeq with the given characters. |
default CharSeq |
peek(CharConsumer action)
Allow the given
CharConsumer to see each element in this CharSeq as it is traversed. |
default CharSeq |
prefix(char... cs)
Prefix the characters in this
CharSeq with the given characters. |
static CharSeq |
range(char start,
char end)
A
Sequence of all the Character values between the given start and end positions, inclusive. |
static CharSeq |
recurse(char seed,
CharUnaryOperator op)
Returns a
CharSeq sequence produced by recursively applying the given operation to the given seed, which
forms the first element of the sequence, the second being f(seed), the third f(f(seed)) and so on. |
default OptionalChar |
reduce(CharBinaryOperator operator)
Reduce this
CharSeq into a single char by iteratively applying the given binary operator to
the current result and each char in the sequence. |
default char |
reduce(char identity,
CharBinaryOperator operator)
Reduce this
CharSeq into a single char by iteratively applying the given binary operator to
the current result and each char in the sequence, starting with the given identity as the initial
result. |
default void |
removeAll()
Remove all elements matched by this sequence using
Iterator.remove(). |
default CharSeq |
repeat()
Repeat this sequence of characters forever, looping back to the beginning when the iterator runs out of chars.
|
default CharSeq |
repeat(long times)
Repeat this sequence of characters x times, looping back to the beginning when the iterator runs out of chars.
|
default CharSeq |
reverse() |
default OptionalChar |
second() |
default CharSeq |
skip(long skip)
Skip a set number of
chars in this CharSeq. |
default CharSeq |
sorted() |
static CharSeq |
startingAt(char start)
A
Sequence of all the Character values starting at the given value and ending at Character.MAX_VALUE. |
default CharSeq |
step(long step)
Skip x number of steps in between each invocation of the iterator of this
CharSeq. |
default CharSeq |
suffix(char... cs)
Suffix the characters in this
CharSeq with the given characters. |
default OptionalChar |
third() |
default char[] |
toArray()
Collect the characters in this
CharSeq into an array. |
default IntSequence |
toInts()
Convert this sequence of characters to a sequence of ints corresponding to the integer value of each character.
|
default IntSequence |
toInts(CharToIntFunction mapper)
Convert this sequence of characters to a sequence of ints corresponding to the integer value of each character.
|
default <T> Sequence<T> |
toSequence(CharFunction<T> mapper)
|
default CharSeq |
until(char terminal)
Terminate this
CharSeq sequence before the given element, with the previous element as the last
element in this CharSeq sequence. |
default CharSeq |
until(CharPredicate terminal)
Terminate this
CharSeq sequence before the element that satisfies the given predicate, with the previous
element as the last element in this CharSeq sequence. |
default Sequence<CharSeq> |
window(int window)
Window the elements of this
CharSeq into a sequence of CharSeqs of elements, each with the size
of the given window. |
default Sequence<CharSeq> |
window(int window,
int step)
Window the elements of this
Sequence into a sequence of CharSeqs of elements, each with the size
of the given window, stepping step elements between each window. |
forEach, forEachChar, from, from, from, iteratorstatic CharSeq empty()
CharSeq with no characters.static CharSeq from(java.util.Iterator<java.lang.Character> iterator)
CharSeq from an Iterator of Character values. Note that CharSeqs created from Iterators cannot be passed over more than once. Further attempts will
register the CharSeq as empty.from in interface CharIterablestatic CharSeq from(CharIterator iterator)
CharSeq from a CharIterator of character values. Note that CharSeqs created from CharIterators cannot be passed over more than once. Further attempts
will
register the CharSeq as empty.from in interface CharIterablestatic CharSeq from(CharIterable iterable)
CharSeq from a CharIterable.static CharSeq from(java.lang.CharSequence csq)
CharSeq from a CharSequence.static CharSeq of(char... cs)
CharSeq with the given characters.of in interface CharIterablestatic CharSeq from(java.util.function.Supplier<? extends CharIterator> iteratorSupplier)
Sequence from Iterators of items supplied by the given Supplier. Every time
the Sequence is to be iterated over, the Supplier is used to create the initial stream of
elements. This is similar to creating a Sequence from an Iterable.static CharSeq from(java.util.stream.Stream<java.lang.Character> stream)
Sequence from a Stream of items. Note that Sequences created from Streams cannot be passed over more than once. Further attempts will cause an IllegalStateException
when the Stream is requested again.from in interface CharIterablejava.lang.IllegalStateException - if the Stream is exhausted.static CharSeq from(java.lang.Iterable<java.lang.Character> iterable)
CharSeq from an Iterable of Character values.from in interface CharIterablestatic CharSeq all()
Sequence of all the Character values starting at Character.MIN_VALUE and ending at
Character.MAX_VALUE.startingAt(char),
range(char, char),
until(char),
endingAt(char)static CharSeq startingAt(char start)
Sequence of all the Character values starting at the given value and ending at Character.MAX_VALUE.all(),
range(char, char),
until(char),
endingAt(char)static CharSeq range(char start, char end)
Sequence of all the Character values between the given start and end positions, inclusive.all(),
startingAt(char),
until(char),
endingAt(char)static CharSeq recurse(char seed, CharUnaryOperator op)
CharSeq sequence produced by recursively applying the given operation to the given seed, which
forms the first element of the sequence, the second being f(seed), the third f(f(seed)) and so on. The returned
CharSeq sequence never terminates naturally.CharSeq sequence produced by recursively applying the given operation to the given seedgenerate(CharSupplier),
endingAt(char),
until(char)static CharSeq generate(CharSupplier supplier)
CharSeq that is generated from the given supplier and thus never terminates.recurse(char, CharUnaryOperator),
endingAt(char),
until(char)default CharSeq until(char terminal)
CharSeq sequence before the given element, with the previous element as the last
element in this CharSeq sequence.default CharSeq endingAt(char terminal)
CharSeq sequence at the given element, including it as the last element in this CharSeq sequence.default CharSeq until(CharPredicate terminal)
CharSeq sequence before the element that satisfies the given predicate, with the previous
element as the last element in this CharSeq sequence.default CharSeq endingAt(CharPredicate terminal)
CharSeq sequence at the element that satisfies the given predicate, including the
element as the last element in this CharSeq sequence.default CharSeq map(CharUnaryOperator mapper)
chars in this CharSeq to another set of chars specified by the given
mapper function.default Sequence<java.lang.Character> box()
chars in this CharSeq to their boxed Character counterparts.default <T> Sequence<T> toSequence(CharFunction<T> mapper)
default CharSeq skip(long skip)
chars in this CharSeq.default CharSeq limit(long limit)
chars returned by this CharSeq.default CharSeq append(java.lang.Iterable<java.lang.Character> iterable)
Characters in the given Iterable to the end of this CharSeq.default CharSeq append(CharIterable that)
default CharSeq append(CharIterator iterator)
chars in the given CharIterator to the end of this CharSeq.
The appended chars will only be available on the first traversal of the resulting CharSeq.
default CharSeq append(java.util.Iterator<java.lang.Character> iterator)
Characters in the given Iterator to the end of this CharSeq.
The appended Characters will only be available on the first traversal of the resulting CharSeq.
default CharSeq append(char... characters)
chars to the end of this CharSeq.default CharSeq append(java.util.stream.Stream<java.lang.Character> stream)
Characters in the given Stream to the end of this CharSeq.
The appended Characters will only be available on the first traversal of the resulting CharSeq.
Further traversals will result in IllegalStateException being thrown.
default CharSeq append(java.util.stream.IntStream stream)
char values of the ints in the given IntStream to the end of this
CharSeq.
The appended chars will only be available on the first traversal of the resulting CharSeq.
Further traversals will result in IllegalStateException being thrown.
default CharSeq filter(CharPredicate predicate)
CharSeq, keeping only the elements that match the given
CharPredicate.default CharSeq filterBack(char firstPrevious, CharBiPredicate predicate)
CharSeq to another sequence of chars while peeking at the previous value in the
sequence.
The predicate has access to the previous int and the current int in the iteration. If the current int is the first value in the sequence, and there is no previous value, the provided replacement value is used as the first previous value.
default CharSeq filterForward(char lastNext, CharBiPredicate predicate)
CharSeq to another sequence of chars while peeking at the next int in the sequence.
The predicate has access to the current int and the next int in the iteration. If the current int is the last value in the sequence, and there is no next value, the provided replacement value is used as the last next value.
default <C> C collect(java.util.function.Supplier<? extends C> constructor,
ObjCharConsumer<? super C> adder)
CharSeq into an arbitrary container using the given constructor and adder.default <C> C collectInto(C result,
ObjCharConsumer<? super C> adder)
CharSeq into the given container using the given adder.default java.lang.String join(java.lang.String delimiter)
CharSeq into a string separated by the given delimiter.default java.lang.String join(java.lang.String prefix,
java.lang.String delimiter,
java.lang.String suffix)
CharSeq into a string separated by the given delimiter, with the given prefix and suffix.default OptionalChar reduce(CharBinaryOperator operator)
CharSeq into a single char by iteratively applying the given binary operator to
the current result and each char in the sequence.default char reduce(char identity,
CharBinaryOperator operator)
CharSeq into a single char by iteratively applying the given binary operator to
the current result and each char in the sequence, starting with the given identity as the initial
result.default OptionalChar first()
CharSeq or an empty OptionalChar if there are no characters
in the CharSeq.default OptionalChar second()
CharSeq or an empty OptionalChar if there are less than two
characters in the CharSeq.default OptionalChar third()
CharSeq or an empty OptionalChar if there are less than
three characters in the CharSeq.default OptionalChar last()
CharSeq or an empty OptionalChar if there are no
characters in the CharSeq.default CharSeq step(long step)
CharSeq.default CharSeq distinct()
CharSeq where each item occurs only once, the first time it is encountered.default OptionalChar min()
CharSeq according to their integer value.default OptionalChar max()
CharSeq according to their integer value.default long count()
CharSeq.default boolean all(CharPredicate predicate)
CharSeq satisfy the given predicate, false otherwise.default boolean none(CharPredicate predicate)
CharSeq satisfy the given predicate, false otherwise.default boolean any(CharPredicate predicate)
CharSeq satisfy the given predicate, false otherwise.default CharSeq peek(CharConsumer action)
CharConsumer to see each element in this CharSeq as it is traversed.default CharSeq sorted()
CharSeq sorted according to the natural order of the characters' integer values.reverse()default char[] toArray()
CharSeq into an array.default CharSeq prefix(char... cs)
CharSeq with the given characters.default CharSeq suffix(char... cs)
CharSeq with the given characters.default CharSeq interleave(CharSeq that)
CharSeq with those of the given CharSeq, stopping when either
sequence finishes.default CharSeq reverse()
CharSeq which iterates over this CharSeq in reverse order.sorted()default java.lang.String asString()
CharSeq concatenated as a string.join(String),
join(String, String, String),
collect(Supplier, ObjCharConsumer)default CharSeq mapBack(char firstPrevious, CharBinaryOperator mapper)
CharSeq to another sequence of characters while peeking at the previous character in the
sequence.
The mapper has access to the previous char and the current char in the iteration. If the current char is the first value in the sequence, and there is no previous value, the provided replacement value is used as the first previous value.
default CharSeq mapForward(char lastNext, CharBinaryOperator mapper)
CharSeq to another sequence of characters while peeking at the next character in the sequence.
The mapper has access to the current char and the next char in the iteration. If the current char is the last value in the sequence, and there is no next value, the provided replacement value is used as the last next value.
default IntSequence toInts()
default IntSequence toInts(CharToIntFunction mapper)
default CharSeq repeat()
The resulting sequence will never terminate if this sequence is non-empty.
default CharSeq repeat(long times)
default Sequence<CharSeq> window(int window)
CharSeq into a sequence of CharSeqs of elements, each with the size
of the given window. The first item in each list is the second item in the previous list. The final list may
be shorter than the window. This is equivalent to window(window, 1).default Sequence<CharSeq> window(int window, int step)
Sequence into a sequence of CharSeqs of elements, each with the size
of the given window, stepping step elements between each window. If the given step is less than the
window size, the windows will overlap each other.default Sequence<CharSeq> batch(int size)
Sequence into a sequence of CharSeqs of distinct elements, each with
the given batch size. This is equivalent to window(size, size).default Sequence<CharSeq> batch(CharBiPredicate predicate)
Sequence into a sequence of CharSeqs of distinct elements, where the
given predicate determines where to split the lists of partitioned elements. The predicate is given the current
and next item in the iteration, and if it returns true a partition is created between the elements.default void removeAll()
Iterator.remove().