Top Description Inners Fields Methods
io.vavr.collection

public Interface Stream<T>

Additional top-level class in compilation unit: StreamModule.

extends LinearSeq<T>
Known Direct Implementers
io.vavr.collection.Stream.Empty, io.vavr.collection.Stream.Cons
Type Parameters
<T>
component type of this Stream
Imports
io.vavr.*, io.vavr.collection.Stream.Cons, .Stream.Empty, io.vavr.collection.StreamModule.*, io.vavr.control.Option, java.io.*, java.util.*, java.util.function.*, java.util.stream.Collector

An immutable Stream is lazy sequence of elements which may be infinitely long. Its immutability makes it suitable for concurrent programming.

A Stream is composed of a head element and a lazy evaluated tail Stream.

There are two implementations of the Stream interface:

Methods to obtain a Stream:

// factory methods
Stream.empty()                  // = Stream.of() = Nil.instance()
Stream.of(x)                    // = new Cons<>(x, Nil.instance())
Stream.of(Object...)            // e.g. Stream.of(1, 2, 3)
Stream.ofAll(Iterable)          // e.g. Stream.ofAll(List.of(1, 2, 3)) = 1, 2, 3
Stream.ofAll(<primitive array>) // e.g. List.ofAll(1, 2, 3) = 1, 2, 3

// int sequences
Stream.from(0)                  // = 0, 1, 2, 3, ...
Stream.range(0, 3)              // = 0, 1, 2
Stream.rangeClosed(0, 3)        // = 0, 1, 2, 3

// generators
Stream.cons(Object, Supplier)   // e.g. Stream.cons(current, () -> next(current));
Stream.continually(Supplier)    // e.g. Stream.continually(Math::random);
Stream.iterate(Object, Function)// e.g. Stream.iterate(1, i -> i * 2);

Factory method applications:

Stream<Integer>       s1 = Stream.of(1);
Stream<Integer>       s2 = Stream.of(1, 2, 3);
                      // = Stream.of(new Integer[] {1, 2, 3});

Stream<int[]>         s3 = Stream.ofAll(1, 2, 3);
Stream<List<Integer>> s4 = Stream.ofAll(List.of(1, 2, 3));

Stream<Integer>       s5 = Stream.ofAll(1, 2, 3);
Stream<Integer>       s6 = Stream.ofAll(List.of(1, 2, 3));

// cuckoo's egg
Stream<Integer[]>     s7 = Stream.<Integer[]> of(new Integer[] {1, 2, 3});

Example: Generating prime numbers

// = Stream(2L, 3L, 5L, 7L, ...)
Stream.iterate(2L, PrimeNumbers::nextPrimeFrom)

// helpers

static long nextPrimeFrom(long num) {
    return Stream.from(num + 1).find(PrimeNumbers::isPrime).get();
}

static boolean isPrime(long num) {
    return !Stream.rangeClosed(2L, (long) Math.sqrt(num)).exists(d -> num % d == 0);
}

See Okasaki, Chris: Purely Functional Data Structures (p. 34 ff.). Cambridge, 2003.
Author
Daniel Dietrich, Jörgen Andersson, Ruslan Sennov

Nested and Inner Type Summary

Modifier and TypeClass and Description
public abstract static class
Stream.Cons<
Component type of the Stream.
T
>

Non-empty Stream, consisting of a head, and tail.

public static class
Stream.Empty<
Component type of the Stream.
T
>

The empty Stream.

Field Summary

Modifier and TypeField and Description
public static final long

Method Summary

Modifier and TypeMethod and Description
public default Stream<T>
append(T
An element
element
)

Implements io.vavr.collection.LinearSeq.append.

Appends an element to this.

public default Stream<T>
appendAll(Iterable<? extends T>
An Iterable of elements
elements
)

Implements io.vavr.collection.LinearSeq.appendAll.

Appends all given elements to this.

public default Stream<T>

Returns:

a new Stream
appendSelf
(Function<? super Stream<T>, ? extends Stream<T>>
an mapper
mapper
)

Appends itself to the end of stream with mapper function.

public default List<T>
asJava()

Implements io.vavr.collection.Seq.asJava.

Creates an immutable java.util.List view on top of this Seq, i.e. calling mutators will result in UnsupportedOperationException at runtime.

public default Stream<T>
asJava(Consumer<? super List<T>>
A side-effecting unit of work that operates on an immutable java.util.List view.
action
)

Implements io.vavr.collection.LinearSeq.asJava.

Creates an immutable java.util.List view on top of this Seq that is passed to the given action.

public default List<T>
asJavaMutable()

Implements io.vavr.collection.Seq.asJavaMutable.

Creates a mutable java.util.List view on top of this Seq, i.e. all mutator methods of the java.util.List are implemented.

public default Stream<T>
asJavaMutable(Consumer<? super List<T>>
A side-effecting unit of work that operates on a mutable java.util.List view.
action
)

Implements io.vavr.collection.LinearSeq.asJavaMutable.

Creates a mutable java.util.List view on top of this Seq that is passed to the given action.

public default <R> Stream<R>
collect(PartialFunction<? super T, ? extends R>
A function that is not necessarily defined of all elements of this traversable.
partialFunction
)

Implements io.vavr.collection.LinearSeq.collect.

Collects all elements that are in the domain of the given partialFunction by mapping the elements to type R.

public static <
Component type of the Stream.
T
>
Collector<T, ArrayList<T>, Stream<T>>

Returns:

A io.vavr.collection.Stream Collector.
collector
()

Returns a java.util.stream.Collector which may be used in conjunction with java.util.stream.Stream#collect(java.util.stream.Collector) to obtain a Stream.

public default Stream<Stream<T>>
combinations()

Implements io.vavr.collection.LinearSeq.combinations.

Returns the union of all combinations from k = 0 to length().

public default Stream<Stream<T>>
combinations(int
Size of subsets
k
)

Implements io.vavr.collection.LinearSeq.combinations.

Returns the k-combination of this traversable, i.e. all subset of this of k distinct elements.

public static <
Component type.
T
>
Stream<T>

Returns:

A new Stream
concat
(Iterable<? extends T>...
The iterables
iterables
)

Lazily creates a Stream in O(1) which traverses along the concatenation of the given iterables.

public static <
Component type.
T
>
Stream<T>

Returns:

A new Stream
concat
(Iterable<? extends Iterable<? extends T>>
The iterable of iterables
iterables
)

Lazily creates a Stream in O(1) which traverses along the concatenation of the given iterables.

public static <
value type
T
>
Stream<T>

Returns:

A new Stream
cons
(T
The head element of the Stream
head
,
Supplier<? extends Stream<? extends T>>
A supplier of the tail values. To end the stream, return Stream#empty.
tailSupplier
)

Constructs a Stream of a head element and a tail supplier.

public static <
value type
T
>
Stream<T>

Returns:

A new Stream
continually
(Supplier<? extends T>
A Supplier of Stream values
supplier
)

Generates an (theoretically) infinitely long Stream using a value Supplier.

public static <
Element type
T
>
Stream<T>

Returns:

A new Stream containing infinite t's.
continually
(T
An element
t
)

Repeats an element infinitely often.

public default Iterator<Stream<T>>
crossProduct(int
the number of cartesian multiplications
power
)

Implements io.vavr.collection.LinearSeq.crossProduct.

Calculates the n-ary cartesian power (or cross product or simply product) of this.

public default Stream<T>

Returns:

A new Stream containing this elements cycled.
cycle
()

Repeat the elements of this Stream infinitely.

public default Stream<T>

Returns:

A new Stream containing this elements cycled count times.
cycle
(int
the number of cycles to be performed
count
)

Repeat the elements of this Stream count times.

public default Stream<T>
distinct()

Implements io.vavr.collection.LinearSeq.distinct.

Returns a new version of this which contains no duplicates.

public default Stream<T>
distinctBy(Comparator<? super T>
A comparator
comparator
)

Implements io.vavr.collection.LinearSeq.distinctBy.

Returns a new version of this which contains no duplicates.

public default <U> Stream<T>
distinctBy(Function<? super T, ? extends U>
A key extractor
keyExtractor
)

Implements io.vavr.collection.LinearSeq.distinctBy.

Returns a new version of this which contains no duplicates.

public default Stream<T>
drop(int
The number of elements to drop.
n
)

Implements io.vavr.collection.LinearSeq.drop.

Drops the first n elements of this or all elements, if this length < n.

public default Stream<T>
dropRight(int
The number of elements to drop.
n
)

Implements io.vavr.collection.LinearSeq.dropRight.

Drops the last n elements of this or all elements, if this length < n.

public default Stream<T>
dropRightUntil(Predicate<? super T>
A condition tested subsequently for this elements, starting from the end.
predicate
)

Implements io.vavr.collection.LinearSeq.dropRightUntil.

Drops elements until the predicate holds for the current element, starting from the end.

public default Stream<T>
dropRightWhile(Predicate<? super T>
A condition tested subsequently for this elements, starting from the end.
predicate
)

Implements io.vavr.collection.LinearSeq.dropRightWhile.

Drops elements while the predicate holds for the current element, starting from the end.

public default Stream<T>
dropUntil(Predicate<? super T>
A condition tested subsequently for this elements.
predicate
)

Implements io.vavr.collection.LinearSeq.dropUntil.

Drops elements until the predicate holds for the current element.

public default Stream<T>
dropWhile(Predicate<? super T>
A condition tested subsequently for this elements.
predicate
)

Implements io.vavr.collection.LinearSeq.dropWhile.

Drops elements while the predicate holds for the current element.

public static <
Component type of Nil, determined by type inference in the particular context.
T
>
Stream<T>

Returns:

The empty list.
empty
()

Returns the single instance of Nil.

public default Stream<T>

Returns:

new Stream composed from this stream extended with a Stream of provided value
extend
(T
value with which the stream should be extended
next
)

Extends (continues) this Stream with a constantly repeated value.

public default Stream<T>

Returns:

new Stream composed from this stream extended with values provided by the supplier
extend
(Supplier<? extends T>
a supplier which will provide values for extending a stream
nextSupplier
)

Extends (continues) this Stream with values provided by a Supplier

public default Stream<T>

Returns:

new Stream composed from this stream extended with values calculated by the provided function
extend
(Function<? super T, ? extends T>
a function which calculates the next value basing on the previous value
nextFunction
)

Extends (continues) this Stream with a Stream of values created by applying consecutively provided Function to the last element of the original Stream.

public static <
Component type of the Stream
T
>
Stream<T>

Returns:

A Stream of size n, where each element contains the result supplied by s.
fill
(int
The number of elements in the Stream
n
,
Supplier<? extends T>
The Supplier computing element values
s
)

Returns a Stream containing n values supplied by a given Supplier s.

public static <
Component type of the Stream
T
>
Stream<T>

Returns:

A Stream of size n, where each element is the given element.
fill
(int
The number of elements in the Stream
n
,
T
The element
element
)

Returns a Stream containing n times the given element

public default Stream<T>
filter(Predicate<? super T>
A predicate
predicate
)

Implements io.vavr.collection.LinearSeq.filter.

Returns a new traversable consisting of all elements which satisfy the given predicate.

public default <U> Stream<U>
flatMap(Function<? super T, ? extends Iterable<? extends U>>
A mapper
mapper
)

Implements io.vavr.collection.LinearSeq.flatMap.

FlatMaps this Traversable.

public static Stream<Integer>

Returns:

a new Stream of int values starting from from
from
(int
a start int value
value
)

Returns an infinitely long Stream of int values starting from from.

public static Stream<Integer>

Returns:

a new Stream of int values starting from from
from
(int
a start int value
value
,
int
the step by which to advance on each next value
step
)

Returns an infinite long Stream of int values starting from value and spaced by step.

public static Stream<Long>

Returns:

a new Stream of long values starting from from
from
(long
a start long value
value
)

Returns an infinitely long Stream of long values starting from from.

public static Stream<Long>

Returns:

a new Stream of long values starting from from
from
(long
a start long value
value
,
long
the step by which to advance on each next value
step
)

Returns an infinite long Stream of long values starting from value and spaced by step.

public default T
get(int
an index
index
)

Implements io.vavr.collection.Seq.get.

Returns the element at the specified index.

public default <C> Map<C, Stream<T>>
groupBy(Function<? super T, ? extends C>
A function which classifies elements into classes
classifier
)

Implements io.vavr.collection.LinearSeq.groupBy.

Groups this elements by classifying the elements.

public default Iterator<Stream<T>>
grouped(int
a positive block size
size
)

Implements io.vavr.collection.LinearSeq.grouped.

Groups this Traversable into fixed size blocks.

public default boolean
hasDefiniteSize()

Implements io.vavr.collection.Traversable.hasDefiniteSize.

Checks if this Traversable is known to have a finite size.

public default int
indexOf(T
an element
element
,
int
start index
from
)

Implements io.vavr.collection.Seq.indexOf.

Returns the index of the first occurrence of the given element after or at some start index or -1 if this does not contain the given element.

public default Stream<T>
init()

Implements io.vavr.collection.LinearSeq.init.

Dual of tail(), returning all elements except the last.

public default Option<Stream<T>>
initOption()

Implements io.vavr.collection.LinearSeq.initOption.

Dual of tailOption(), returning all elements except the last as Option.

public default Stream<T>
insert(int
an index
index
,
T
an element
element
)

Implements io.vavr.collection.LinearSeq.insert.

Inserts the given element at the specified index.

public default Stream<T>
insertAll(int
an index
index
,
Iterable<? extends T>
An Iterable of elements
elements
)

Implements io.vavr.collection.LinearSeq.insertAll.

Inserts the given elements at the specified index.

public default Stream<T>
intersperse(T
An element.
element
)

Implements io.vavr.collection.LinearSeq.intersperse.

Inserts an element between all elements of this Traversable.

public default boolean

Returns:

false
isAsync
()

Implements io.vavr.Value.isAsync.

A Stream is computed synchronously.

public default boolean

Returns:

true
isLazy
()

Implements io.vavr.Value.isLazy.

A Stream is computed lazily.

public default boolean
isTraversableAgain()

Implements io.vavr.collection.Traversable.isTraversableAgain.

Checks if this Traversable can be repeatedly traversed.

public static <
value type
T
>
Stream<T>

Returns:

A new Stream
iterate
(T
The first value in the Stream
seed
,
Function<? super T, ? extends T>
A function to calculate the next value based on the previous
f
)

Generates a (theoretically) infinitely long Stream using a function to calculate the next value based on the previous.

public static <
value type
T
>
Stream<T>

Returns:

A new Stream
iterate
(Supplier<? extends Option<? extends T>>
A Supplier of iterator values
supplier
)

Generates a (theoretically) infinitely long Stream using a repeatedly invoked supplier that provides a Some for each next value and a None for the end.

public default T
last()

Implements io.vavr.collection.Traversable.last.

Dual of head(), returning the last element.

public default int
lastIndexOf(T
an element
element
,
int
the end index
end
)

Implements io.vavr.collection.Seq.lastIndexOf.

Returns the index of the last occurrence of the given element before or at a given end index or -1 if this does not contain the given element.

public default Stream<T>
leftPadTo(int
the target length
length
,
T
the padding element
element
)

Implements io.vavr.collection.Seq.leftPadTo.

A copy of this sequence with an element prepended until a given target length is reached.

public default int
length()

Implements io.vavr.collection.Traversable.length.

Computes the number of elements of this Traversable.

public default <U> Stream<U>
map(Function<? super T, ? extends U>
A mapper.
mapper
)

Implements io.vavr.collection.LinearSeq.map.

Maps the elements of this Traversable to elements of a new type preserving their order, if any.

public static <
Component type of the Stream.
T
>
Stream<T>

Returns:

the given stream instance as narrowed type Stream<T>.
narrow
(Stream<? extends T>
A Stream.
stream
)

Narrows a widened Stream<?

public static <
The component type
T
>
Stream<T>

Returns:

A new Stream instance containing the given element
of
(T
An element.
element
)

Returns a singleton Stream, i.e. a Stream of one element.

public static <
Component type of the Stream.
T
>
Stream<T>

Returns:

A list containing the given elements in the same order.
of
(T...
Zero or more elements.
elements
)

Creates a Stream of the given elements.

public static <
Component type of the Stream.
T
>
Stream<T>

Returns:

A Stream containing the given elements in the same order.
ofAll
(Iterable<? extends T>
An Iterable of elements.
elements
)

Creates a Stream of the given elements.

public static <
Component type of the Stream.
T
>
Stream<T>

Returns:

A Stream containing the given elements in the same order.
ofAll
(Stream<? extends T> javaStream)

Creates a Stream that contains the elements of the given java.util.stream.Stream.

public static Stream<Boolean>

Returns:

A new Stream of Boolean values
ofAll
(boolean...
boolean values
elements
)

Creates a Stream from boolean values.

public static Stream<Byte>

Returns:

A new Stream of Byte values
ofAll
(byte...
byte values
elements
)

Creates a Stream from byte values.

public static Stream<Character>

Returns:

A new Stream of Character values
ofAll
(char...
char values
elements
)

Creates a Stream from char values.

public static Stream<Double>

Returns:

A new Stream of Double values
ofAll
(double...
double values
elements
)

Creates a Stream values double values.

public static Stream<Float>

Returns:

A new Stream of Float values
ofAll
(float...
float values
elements
)

Creates a Stream from float values.

public static Stream<Integer>

Returns:

A new Stream of Integer values
ofAll
(int...
int values
elements
)

Creates a Stream from int values.

public static Stream<Long>

Returns:

A new Stream of Long values
ofAll
(long...
long values
elements
)

Creates a Stream from long values.

public static Stream<Short>

Returns:

A new Stream of Short values
ofAll
(short...
short values
elements
)

Creates a Stream from short values.

public default Stream<T>
orElse(Iterable<? extends T>
An alternative Traversable
other
)

Implements io.vavr.collection.LinearSeq.orElse.

Returns this Traversable if it is nonempty, otherwise return the alternative.

public default Stream<T>
orElse(Supplier<? extends Iterable<? extends T>>
An alternative Traversable supplier
supplier
)

Implements io.vavr.collection.LinearSeq.orElse.

Returns this Traversable if it is nonempty, otherwise return the result of evaluating supplier.

public default Stream<T>
padTo(int
the target length
length
,
T
the padding element
element
)

Implements io.vavr.collection.LinearSeq.padTo.

A copy of this sequence with an element appended until a given target length is reached.

public default Tuple2<Stream<T>, Stream<T>>
partition(Predicate<? super T>
A predicate which classifies an element if it is in the first or the second traversable.
predicate
)

Implements io.vavr.collection.LinearSeq.partition.

Creates a partition of this Traversable by splitting this elements in two in distinct traversables according to a predicate.

public default Stream<T>
patch(int
the index of the first replaced element
from
,
Iterable<? extends T>
sequence for replacement
that
,
int
the number of elements to drop in the original list
replaced
)

Implements io.vavr.collection.LinearSeq.patch.

Produces a new list where a slice of elements in this list is replaced by another sequence.

public default Stream<T>
peek(Consumer<? super T>
The action that will be performed on the element(s).
action
)

Implements io.vavr.collection.LinearSeq.peek.

Performs the given action on the first element if this is an eager implementation.

public default Stream<Stream<T>>
permutations()

Implements io.vavr.collection.LinearSeq.permutations.

Computes all unique permutations.

public default Stream<T>
prepend(T
An element
element
)

Implements io.vavr.collection.LinearSeq.prepend.

Prepends an element to this.

public default Stream<T>
prependAll(Iterable<? extends T>
An Iterable of elements
elements
)

Implements io.vavr.collection.LinearSeq.prependAll.

Prepends all given elements to this.

public static Stream<Character>
range(char from, char toExclusive)

public static Stream<Integer>

Returns:

a range of int values as specified or Nil if from >= toExclusive
range
(int
the first number
from
,
int
the last number + 1
toExclusive
)

Creates a Stream of int numbers starting from from, extending to toExclusive - 1.

public static Stream<Long>

Returns:

a range of long values as specified or Nil if from >= toExclusive
range
(long
the first number
from
,
long
the last number + 1
toExclusive
)

Creates a Stream of long numbers starting from from, extending to toExclusive - 1.

public static Stream<Character>
rangeBy(char from, char toExclusive, int step)

public static Stream<Double>
rangeBy(double from, double toExclusive, double step)

public static Stream<Integer>

Returns:

a range of long values as specified or Nil if
from >= toInclusive and step > 0 or
from <= toInclusive and step < 0
rangeBy
(int
the first number
from
,
int
the last number + 1
toExclusive
,
int
the step
step
)

Creates a Stream of int numbers starting from from, extending to toExclusive - 1, with step.

public static Stream<Long>

Returns:

a range of long values as specified or Nil if
from >= toInclusive and step > 0 or
from <= toInclusive and step < 0
rangeBy
(long
the first number
from
,
long
the last number + 1
toExclusive
,
long
the step
step
)

Creates a Stream of long numbers starting from from, extending to toExclusive - 1, with step.

public static Stream<Character>
rangeClosed(char from, char toInclusive)

public static Stream<Integer>

Returns:

a range of int values as specified or Nil if from > toInclusive
rangeClosed
(int
the first number
from
,
int
the last number
toInclusive
)

Creates a Stream of int numbers starting from from, extending to toInclusive.

public static Stream<Long>

Returns:

a range of long values as specified or Nil if from > toInclusive
rangeClosed
(long
the first number
from
,
long
the last number
toInclusive
)

Creates a Stream of long numbers starting from from, extending to toInclusive.

public static Stream<Character>
rangeClosedBy(char from, char toInclusive, int step)

public static Stream<Double>
rangeClosedBy(double from, double toInclusive, double step)

public static Stream<Integer>

Returns:

a range of int values as specified or Nil if
from > toInclusive and step > 0 or
from < toInclusive and step < 0
rangeClosedBy
(int
the first number
from
,
int
the last number
toInclusive
,
int
the step
step
)

Creates a Stream of int numbers starting from from, extending to toInclusive, with step.

public static Stream<Long>

Returns:

a range of int values as specified or Nil if
from > toInclusive and step > 0 or
from < toInclusive and step < 0
rangeClosedBy
(long
the first number
from
,
long
the last number
toInclusive
,
long
the step
step
)

Creates a Stream of long numbers starting from from, extending to toInclusive, with step.

public default Stream<T>
reject(Predicate<? super T>
A predicate
predicate
)

Implements io.vavr.collection.LinearSeq.reject.

Returns a new traversable consisting of all elements which do not satisfy the given predicate.

public default Stream<T>
remove(T
An element to be removed from this Seq.
element
)

Implements io.vavr.collection.LinearSeq.remove.

Removes the first occurrence of the given element.

public default Stream<T>
removeAll(T
An element to be removed from this Seq.
element
)

Implements io.vavr.collection.LinearSeq.removeAll.

Removes all occurrences of the given element.

public default Stream<T>
removeAll(Iterable<? extends T>
Elements to be removed from this Seq.
elements
)

Implements io.vavr.collection.LinearSeq.removeAll, io.vavr.collection.LinearSeq.removeAll.

Removes all occurrences of the given elements.

public default Stream<T>
removeAll(Predicate<? super T>
the predicate used to test elements
predicate
)

Implements io.vavr.collection.LinearSeq.removeAll, io.vavr.collection.LinearSeq.removeAll.

Deprecated

Returns a new Seq consisting of all elements which do not satisfy the given predicate.

public default Stream<T>
removeAt(int
position of element to remove
index
)

Implements io.vavr.collection.LinearSeq.removeAt.

Removes the element at the specified position in this sequence.

public default Stream<T>
removeFirst(Predicate<T>
an predicate
predicate
)

Implements io.vavr.collection.LinearSeq.removeFirst.

Removes the first occurrence that satisfy predicate

public default Stream<T>
removeLast(Predicate<T>
an predicate
predicate
)

Implements io.vavr.collection.LinearSeq.removeLast.

Removes the last occurrence that satisfy predicate

public default Stream<T>
replace(T
An element to be substituted.
currentElement
,
T
A replacement for currentElement.
newElement
)

Implements io.vavr.collection.LinearSeq.replace.

Replaces the first occurrence (if exists) of the given currentElement with newElement.

public default Stream<T>
replaceAll(T
An element to be substituted.
currentElement
,
T
A replacement for currentElement.
newElement
)

Implements io.vavr.collection.LinearSeq.replaceAll.

Replaces all occurrences of the given currentElement with newElement.

public default Stream<T>
retainAll(Iterable<? extends T>
Elements to be kept.
elements
)

Implements io.vavr.collection.LinearSeq.retainAll.

Keeps all occurrences of the given elements from this.

public default Stream<T>
reverse()

Implements io.vavr.collection.LinearSeq.reverse.

Reverses the order of elements.

public default Stream<T>
rotateLeft(int
distance of left rotation
n
)

Implements io.vavr.collection.LinearSeq.rotateLeft.

Circular rotates the elements by the specified distance to the left direction.

public default Stream<T>
rotateRight(int
distance of right rotation
n
)

Implements io.vavr.collection.LinearSeq.rotateRight.

Circular rotates the elements by the specified distance to the right direction.

public default Stream<T>
scan(T
neutral element for the operator op
zero
,
BiFunction<? super T, ? super T, ? extends T>
the associative operator for the scan
operation
)

Implements io.vavr.collection.LinearSeq.scan.

Computes a prefix scan of the elements of the collection.

public default <U> Stream<U>
scanLeft(U
the initial value
zero
,
BiFunction<? super U, ? super T, ? extends U>
the binary operator applied to the intermediate result and the element
operation
)

Implements io.vavr.collection.LinearSeq.scanLeft.

Produces a collection containing cumulative results of applying the operator going left to right.

public default <U> Stream<U>
scanRight(U
the initial value
zero
,
BiFunction<? super T, ? super U, ? extends U>
the binary operator applied to the intermediate result and the element
operation
)

Implements io.vavr.collection.LinearSeq.scanRight.

Produces a collection containing cumulative results of applying the operator going right to left.

public default Stream<T>
shuffle()

Implements io.vavr.collection.LinearSeq.shuffle.

Randomize the order of the elements in the current sequence.

public default Stream<T>
slice(int
the beginning index, inclusive
beginIndex
,
int
the end index, exclusive
endIndex
)

Implements io.vavr.collection.LinearSeq.slice.

Returns a Seq that is a slice of this.

public default Iterator<Stream<T>>
slideBy(Function<? super T, ?>
A function which classifies elements into classes
classifier
)

Implements io.vavr.collection.LinearSeq.slideBy.

Slides a non-overlapping window of a variable size over this Traversable.

public default Iterator<Stream<T>>
sliding(int
a positive window size
size
)

Implements io.vavr.collection.LinearSeq.sliding.

Slides a window of a specific size and step size 1 over this Traversable by calling sliding(int, int).

public default Iterator<Stream<T>>
sliding(int
a positive window size
size
,
int
a positive step size
step
)

Implements io.vavr.collection.LinearSeq.sliding.

Slides a window of a specific size and step size over this Traversable.

public default <U extends Comparable<? super U>> Stream<T>
sortBy(Function<? super T, ? extends U>
A mapper
mapper
)

Implements io.vavr.collection.LinearSeq.sortBy.

Sorts this elements by comparing the elements in a different domain, using the given mapper.

public default <U> Stream<T>
sortBy(Comparator<? super U>
A comparator
comparator
,
Function<? super T, ? extends U>
A mapper
mapper
)

Implements io.vavr.collection.LinearSeq.sortBy.

Sorts this elements by comparing the elements in a different domain, using the given mapper.

public default Stream<T>
sorted()

Implements io.vavr.collection.LinearSeq.sorted.

Sorts this elements according to their natural order.

public default Stream<T>
sorted(Comparator<? super T>
A comparator
comparator
)

Implements io.vavr.collection.LinearSeq.sorted.

Sorts this elements according to the provided Comparator.

public default Tuple2<Stream<T>, Stream<T>>
span(Predicate<? super T>
A predicate.
predicate
)

Implements io.vavr.collection.LinearSeq.span.

Returns a tuple where the first element is the longest prefix of elements that satisfy the given predicate and the second element is the remainder.

public default Tuple2<Stream<T>, Stream<T>>
splitAt(int
An index.
n
)

Implements io.vavr.collection.Seq.splitAt.

Splits a Seq at the specified index.

public default Tuple2<Stream<T>, Stream<T>>
splitAt(Predicate<? super T>
An predicate
predicate
)

Implements io.vavr.collection.Seq.splitAt.

Splits a sequence at the first element which satisfies the Predicate, e.g. Tuple(init, element+tail).

public default Tuple2<Stream<T>, Stream<T>>
splitAtInclusive(Predicate<? super T>
An predicate
predicate
)

Implements io.vavr.collection.Seq.splitAtInclusive.

Splits a sequence at the first element which satisfies the Predicate, e.g. Tuple(init+element, tail).

public default String
stringPrefix()

Implements io.vavr.Value.stringPrefix.

Returns the name of this Value type, which is used by toString().

public default Stream<T>
subSequence(int
the beginning index, inclusive
beginIndex
)

Implements io.vavr.collection.LinearSeq.subSequence.

Returns a Seq that is a subsequence of this.

public default Stream<T>
subSequence(int
the beginning index, inclusive
beginIndex
,
int
the end index, exclusive
endIndex
)

Implements io.vavr.collection.LinearSeq.subSequence.

Returns a Seq that is a subsequence of this.

public static <
Component type of the Stream
T
>
Stream<T>

Returns:

A Stream consisting of elements f(0),f(1), ..., f(n - 1)
tabulate
(int
The number of elements in the Stream
n
,
Function<? super Integer, ? extends T>
The Function computing element values
f
)

Returns a Stream containing n values of a given Function f over a range of integer values from 0 to n - 1.

public Stream<T>
tail()

Redeclares io.vavr.collection.LinearSeq.tail.

Drops the first element of a non-empty Traversable.

public default Option<Stream<T>>
tailOption()

Implements io.vavr.collection.LinearSeq.tailOption.

Drops the first element of a non-empty Traversable and returns an Option.

public default Stream<T>
take(int
The number of elements to take.
n
)

Implements io.vavr.collection.LinearSeq.take.

Takes the first n elements of this or all elements, if this length < n.

public default Stream<T>
takeRight(int
The number of elements to take.
n
)

Implements io.vavr.collection.LinearSeq.takeRight.

Takes the last n elements of this or all elements, if this length < n.

public default Stream<T>
takeRightUntil(Predicate<? super T>
A condition tested subsequently for this elements, starting from the end.
predicate
)

Implements io.vavr.collection.LinearSeq.takeRightUntil.

Takes elements until the predicate holds for the current element, starting from the end.

public default Stream<T>
takeRightWhile(Predicate<? super T>
A condition tested subsequently for this elements, starting from the end.
predicate
)

Implements io.vavr.collection.LinearSeq.takeRightWhile.

Takes elements while the predicate holds for the current element, starting from the end.

public default Stream<T>
takeUntil(Predicate<? super T>
A condition tested subsequently for this elements.
predicate
)

Implements io.vavr.collection.LinearSeq.takeUntil.

Takes elements until the predicate holds for the current element.

public default Stream<T>
takeWhile(Predicate<? super T>
A condition tested subsequently for the contained elements.
predicate
)

Implements io.vavr.collection.LinearSeq.takeWhile.

Takes elements while the predicate holds for the current element.

public default <
Type of transformation result
U
>
U

Returns:

An instance of type U
transform
(Function<? super Stream<T>, ? extends U>
A transformation
f
)

Transforms this Stream.

public static <
matrix element type
T
>
Stream<Stream<T>>

Returns:

a transposed Stream matrix.
transpose
(Stream<Stream<T>>
to be transposed.
matrix
)

Transposes the rows and columns of a Stream matrix.

public static <
type of seeds and unfolded values
T
>
Stream<T>

Returns:

a Stream with the values built up by the iteration
unfold
(T
the start value for the iteration
seed
,
Function<? super T, Option<Tuple2<? extends T, ? extends T>>>
the function to get the next step of the iteration
f
)

Creates a Stream from a seed value and a function.

public static <
type of seeds
T
,
type of unfolded values
U
>
Stream<U>

Returns:

a Stream with the values built up by the iteration
unfoldLeft
(T
the start value for the iteration
seed
,
Function<? super T, Option<Tuple2<? extends T, ? extends U>>>
the function to get the next step of the iteration
f
)

Creates a Stream from a seed value and a function.

public static <
type of seeds
T
,
type of unfolded values
U
>
Stream<U>

Returns:

a Stream with the values built up by the iteration
unfoldRight
(T
the start value for the iteration
seed
,
Function<? super T, Option<Tuple2<? extends U, ? extends T>>>
the function to get the next step of the iteration
f
)

Creates a Stream from a seed value and a function.

public default <T1, T2> Tuple2<Stream<T1>, Stream<T2>>
unzip(Function<? super T, Tuple2<? extends T1, ? extends T2>>
a function which converts elements of this to pairs
unzipper
)

Implements io.vavr.collection.LinearSeq.unzip.

Unzips this elements by mapping this elements to pairs which are subsequently split into two distinct sets.

public default <T1, T2, T3> Tuple3<Stream<T1>, Stream<T2>, Stream<T3>>
unzip3(Function<? super T, Tuple3<? extends T1, ? extends T2, ? extends T3>>
a function which converts elements of this to pairs
unzipper
)

Implements io.vavr.collection.Seq.unzip3.

Unzips this elements by mapping this elements to triples which are subsequently split into three distinct sets.

public default Stream<T>
update(int
an index
index
,
T
an element
element
)

Implements io.vavr.collection.LinearSeq.update.

Updates the given element at the specified index.

public default Stream<T>
update(int
an index
index
,
Function<? super T, ? extends T>
a function transforming the previous value
updater
)

Implements io.vavr.collection.LinearSeq.update, io.vavr.collection.LinearSeq.update.

Updates the given element at the specified index using the specified function.

public default <U> Stream<Tuple2<T, U>>
zip(Iterable<? extends U>
The Iterable providing the second half of each result pair.
that
)

Implements io.vavr.collection.LinearSeq.zip.

Returns a traversable formed from this traversable and another Iterable collection by combining corresponding elements in pairs.

public default <U> Stream<Tuple2<T, U>>
zipAll(Iterable<? extends U>
The Iterable providing the second half of each result pair.
iterable
,
T
The element to be used to fill up the result if this traversable is shorter than that.
thisElem
,
U
The element to be used to fill up the result if that is shorter than this traversable.
thatElem
)

Implements io.vavr.collection.LinearSeq.zipAll.

Returns a traversable formed from this traversable and another Iterable by combining corresponding elements in pairs.

public default <U, R> Stream<R>
zipWith(Iterable<? extends U>
The Iterable providing the second parameter of the mapper.
that
,
BiFunction<? super T, ? super U, ? extends R>
a mapper.
mapper
)

Implements io.vavr.collection.LinearSeq.zipWith.

Returns a traversable formed from this traversable and another Iterable collection by mapping elements.

public default Stream<Tuple2<T, Integer>>
zipWithIndex()

Implements io.vavr.collection.LinearSeq.zipWithIndex.

Zips this traversable with its indices.

public default <U> Stream<U>
zipWithIndex(BiFunction<? super T, ? super Integer, ? extends U>
a mapper.
mapper
)

Implements io.vavr.collection.LinearSeq.zipWithIndex.

Zips this traversable with its indices by applying mapper provided.

Inherited from io.vavr.collection.LinearSeq:
asPartialFunctionindexOfSliceindexWhereisDefinedAtlastIndexOfSlicelastIndexWherenarrowreverseIteratorsearchsearchsegmentLength