Class Stream<A>
java.lang.Object
fj.data.Stream<A>
- All Implemented Interfaces:
Iterable<A>
- Direct Known Subclasses:
Stream.Cons, Stream.Nil
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final classprivate static final class -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAppends the given stream to this stream.Appends the given stream to this stream.final <B> Stream<B> Performs function application within a stream (applicative functor pattern).final A[]Returns an array from this stream.static <A> Stream<A> arrayStream(A... as) static StringReturns a string from the given stream of characters.final <B,C, D, E, F$, G, H, I>
Stream<I> bind(Stream<B> sb, Stream<C> sc, Stream<D> sd, Stream<E> se, Stream<F$> sf, Stream<G> sg, Stream<H> sh, F<A, F<B, F<C, F<D, F<E, F<F$, F<G, F<H, I>>>>>>>> f) Binds the given function across each element of this stream and the given streams with a final join.final <B,C, D, E, F$, G, H>
Stream<H> bind(Stream<B> sb, Stream<C> sc, Stream<D> sd, Stream<E> se, Stream<F$> sf, Stream<G> sg, F<A, F<B, F<C, F<D, F<E, F<F$, F<G, H>>>>>>> f) Binds the given function across each element of this stream and the given streams with a final join.final <B,C, D, E, F$, G>
Stream<G> bind(Stream<B> sb, Stream<C> sc, Stream<D> sd, Stream<E> se, Stream<F$> sf, F<A, F<B, F<C, F<D, F<E, F<F$, G>>>>>> f) Binds the given function across each element of this stream and the given streams with a final join.final <B,C, D, E, F$>
Stream<F$> Binds the given function across each element of this stream and the given streams with a final join.final <B,C, D, E> Stream <E> Binds the given function across each element of this stream and the given streams with a final join.final <B,C, D> Stream <D> Binds the given function across each element of this stream and the given streams with a final join.final <B,C> Stream <C> Binds the given function across each element of this stream and the given stream with a final join.final <B,C> Stream <C> Binds the given function across each element of this stream and the given stream with a final join.final <B> Stream<B> Binds the given function across each element of this stream with a final join.bind_()A first-class version of the bind function.final <B> Stream<B> Binds the given function across the stream of substreams of this stream.cons()Returns a function that prepends (cons) an element to a stream to produce a new stream.Prepends (cons) the given element to this stream to product a new stream.static <A> Stream<A> Prepends the given head element to the given tail element to produce a new stream.cons_()Returns a function that prepends (cons) an element to a stream to produce a new stream.static <A> Stream<A> Returns an infinite-length stream of the given elements cycling.drop(int i) Drops the given number of elements from the head of this stream if they are available.Removes elements from the head of this stream that do not match the given predicate function until an element is found that does match or the stream is exhausted.static <A> Stream<A> enumerationStream(Enumeration<A> e) final booleanfinal booleanReturnstrueif the predicate holds for at least one of the elements of this stream,falseotherwise (falsefor the empty stream).filter()Returns a first-class version of the filter function.Filters elements from this stream by returning only elements which producetruewhen the given function is applied to them.Finds the first occurrence of an element that matches the given predicate or no value if no elements match.final <B> BPerforms a left-fold reduction across this stream.final <B> BPerforms a left-fold reduction across this stream.final ATakes the first 2 elements of the stream and applies the function to them, then applies the function to the result and the third element and so on.final ATakes the first 2 elements of the stream and applies the function to them, then applies the function to the result and the third element and so on.A first-class version of the foldRight function.final <B> BPerforms a right-fold reduction across this stream.final <B> BPerforms a right-fold reduction across this stream.final <B> BfoldRight1(F<A, F<B, B>> f, B b) Performs a right-fold reduction across this stream.final <B> BfoldRight1(F2<A, B, B> f, B b) Performs a right-fold reduction across this stream.final booleanReturnstrueif the predicate holds for all of the elements of this stream,falseotherwise (truefor the empty stream).final UnitPerforms a side-effect for each element of this stream.final voidforeachDoEffect(Effect1<A> f) Performs a side-effect for each element of this stream.static <A> Stream<A> forever(Enumerator<A> e, A from) Returns a stream that is either infinite or bounded up to the maximum value of the given iterator starting at the given value and stepping at increments of1.static <A> Stream<A> forever(Enumerator<A> e, A from, long step) Returns a stream that is either infinite or bounded up to the maximum value of the given iterator starting at the given value and stepping at the given increment.static <A,B> Stream <A> fromFunction(Enumerator<B> e, F<B, A> f, B i) Converts a function of an enumerable type to a stream of the results of that function, starting at the given index.static <A> Stream<A> fromFunction(F<Natural, A> f) Converts a function of natural numbers to a stream.fromString(String s) Returns a stream of characters from the given string.final inthashCode()abstract Ahead()The first element of the stream or fails for the empty stream.final Aindex(int i) Returns the element at the given index if it exists, fails otherwise.Returns the position of the first element matching the given predicate, if any.inits()Returns a stream of all prefixes of this stream.interleave(Stream<A> as) Interleaves the given stream with this stream to produce a new stream.intersperse(A a) Intersperses the given value between each two elements of the stream.final booleanisEmpty()Returnstrueif this stream is empty,falseotherwise.isEmpty_()Returns a function that determines whether a given stream is empty.final booleanReturnsfalseif this stream is empty,trueotherwise.Returns a function that determines whether a given stream is not empty.static <A> Stream<A> iterableStream(Iterable<A> i) Takes the given iterable to a stream.iterate()A first-class version of the iterate function.static <A> Stream<A> Returns a stream constructed by applying the given iteration function starting at the given value.static <A> Stream<A> iterateWhile(F<A, A> f, F<A, Boolean> p, A a) Creates a stream where the first item is calculated by applying the function on the third argument, the second item by applying the function on the previous result and so on.iterator()Returns an iterator for this stream.static <A> Stream<A> iteratorStream(Iterator<A> it) Constructs a stream with the given elements in the Iterator.join()A first-class version of joinstatic <A> Stream<A> Joins the given stream of streams by concatenation.final Alast()Get the last element of this stream.final intlength()The length of this stream.final <B> Stream<B> Maps the given function across this stream.map_()Provides a first-class version of the map function.Maps the given function of arity-2 across this stream and returns a function that applies all the resulting functions to a given argument.private static <A> Stream<A> mergePairs(Ord<A> o, Stream<Stream<A>> s) private static <A> Stream<A> Returns a new stream of all the items in this stream that do not appear in the given stream.static <A> Stream<A> nil()Returns an empty stream.nil_()Returns an empty stream.final AReturns the head of this stream if there is one or the given argument if this stream is empty.Returns the tail of this stream if there is one or the given argument if this stream is empty.range(int from) Returns an infinite stream of integers from the givenfromvalue (inclusive).range(int from, long to) Returns a stream of integers from the givenfromvalue (inclusive) to the giventovalue (exclusive).static <A> Stream<A> range(Enumerator<A> e, A from, A to) Returns a stream using the given enumerator from the given value to the other given value stepping at increments of1.static <A> Stream<A> range(Enumerator<A> e, A from, A to, long step) Returns a stream using the given enumerator from the given value to the other given value stepping at the given increment.Filters elements from this stream by returning only elements which producefalsewhen the given function is applied to them.static <A> Stream<A> repeat(A a) Returns an infinite-length stream of the given element.Returns a new stream resulting from replacing all elements that match the given predicate with the given element.reverse()Reverse this stream in constant stack space.Sequence through the Stream monad.Sequence through the Stream monad.final <B> Stream<B> Performs a bind across each stream element, but ignores the element value each time.Sequence through the Stream monad.Turn a stream of functions into a function returning a stream.sequenceEither(Stream<Either<L, B>> stream) Sequence the given stream and collect the output on the right side of an either.sequenceEitherLeft(Stream<Either<B, R>> stream) Sequence the given stream and collect the output on the left side of an either.sequenceEitherRight(Stream<Either<L, B>> stream) Sequence the given stream and collect the output on the right side of an either.Sequence the given stream and collect the output as a function.sequenceIO(Stream<IO<B>> stream) Sequence the given stream and collect the output as an IO.sequenceList(Stream<List<B>> stream) Sequence the given stream and collect the output as a list.sequenceOption(Stream<Option<B>> stream) Sequence the given stream and collect the output as an stream.sequenceP1(Stream<P1<B>> stream) Sequence the given stream and collect the output as a P1.sequenceSeq(Stream<Seq<B>> stream) Sequence the given stream and collect the output as a seq.sequenceSet(Ord<B> ord, Stream<Set<B>> stream) Sequence the given stream and collect the output as a set; use the given ord to order the set.sequenceStream(Stream<Stream<B>> stream) Sequence the given stream and collect the output as a stream.static <B> Trampoline<Stream<B>> sequenceTrampoline(Stream<Trampoline<B>> stream) Sequence the given stream and collect the output as a trampoline.static <E,B> Validation <E, Stream<B>> sequenceValidation(Stream<Validation<E, B>> stream) Sequence the given stream and collect the output as a validation.static <E,B> Validation <E, Stream<B>> sequenceValidation(Semigroup<E> semigroup, Stream<Validation<E, B>> stream) Sequence the given stream and collect the output as a validation; use the given semigroup to reduce the errors.final <B> Stream<B> Applies a stream of comonadic functions to this stream, returning a stream of values.single()Returns a function that yields a stream containing its argument.static <A> Stream<A> single(A a) Returns a stream of one element containing the given value.Append the given element to this stream to product a new stream.Append the given element to this stream to produce a new stream.Sort this stream according to the given ordering.Sort this stream according to the given ordering, using a parallel Quick Sort algorithm that uses the given parallelisation strategy.Returns a tuple where the first element is the longest prefix of this stream that satisfies the given predicate and the second element is the remainder of the stream.Returns a tuple where the first element is the longest prefix of this stream that does not satisfy the given predicate and the second element is the remainder of the stream.static <A> Stream<A> stream(A... as) Constructs a stream with the given elements.Returns a stream of all infixes of this stream.tail()The stream without the first element or fails for the empty stream.tails()Returns a stream of the suffixes of this stream.take(int n) Returns the firstnelements from the head of this stream.Returns the first elements of the head of this stream that match the given predicate function.toArray()Returns a array projection of this stream.Returns a array projection of this stream.final Collection<A> Projects an immutable collection of this stream.Returns an either projection of this stream; the given argument inLeftif empty, or the first element inRight.Converts this stream to a function of natural numbers.Returns a java.util.List projection of this stream.toList()Returns a list projection of this stream.toOption()Returns an option projection of this stream;Noneif empty, or the first element inSome.final StringtoString()final Stringfinal StringtraverseEither(F<A, Either<L, B>> f) Traverse this stream with the given function and collect the output on the right side of an either.traverseEitherLeft(F<A, Either<B, R>> f) Traverse this stream with the given function and collect the output on the left side of an either.traverseEitherRight(F<A, Either<L, B>> f) Traverse this stream with the given function and collect the output on the right side of an either.Traverse this stream with the given function and collect the output as a function.traverseIO(F<A, IO<B>> f) Traverse this stream with the given function and collect the output as an IO.traverseList(F<A, List<B>> f) Traverse this stream with the given function and collect the output as a list.traverseOption(F<A, Option<B>> f) Traverses through the Seq with the given functiontraverseP1(F<A, P1<B>> f) Traverse this stream with the given function and collect the output as a p1.traverseSeq(F<A, Seq<B>> f) Traverse this stream with the given function and collect the output as a seq.traverseSet(Ord<B> ord, F<A, Set<B>> f) Traverse this stream with the given function and collect the output as a set; use the given ord to order the set.traverseStream(F<A, Stream<B>> f) Traverse this stream with the given function and collect the output as a stream.<B> Trampoline<Stream<B>> traverseTrampoline(F<A, Trampoline<B>> f) Traverse this stream with the given function and collect the output as a trampoline.final <E,B> Validation <E, Stream<B>> traverseValidation(F<A, Validation<E, B>> f) Traverse this stream with the given function and collect the output as a validation.final <E,B> Validation <E, Stream<B>> traverseValidation(Semigroup<E> semigroup, F<A, Validation<E, B>> f) Traverse this stream with the given function and collect the output as a validation; use the given semigroup to reduce the errors.final <B> BPerforms a reduction on this stream using the given arguments.static <A,B> Stream <A> Unfolds across the given function starting at the given value to produce a stream.Transforms a stream of pairs into a stream of first components and a stream of second components.final <B> Stream<B> Zips this stream with the given stream of functions, applying each function in turn to the corresponding element in this stream to produce a new stream.Zips this stream with the given stream to produce a stream of pairs.zipIndex()Zips this stream with the index of its element as a pair.zipWith()A first-class version of the zipWith function.final <B,C> Stream <C> Zips this stream with the given stream using the given function to produce a new stream.final <B,C> Stream <C> Zips this stream with the given stream using the given function to produce a new stream.Partially-applied version of zipWith.Methods inherited from interface Iterable
forEach, spliterator
-
Constructor Details
-
Stream
private Stream()
-
-
Method Details
-
iterator
-
head
The first element of the stream or fails for the empty stream.- Returns:
- The first element of the stream or fails for the empty stream.
-
tail
-
isEmpty
public final boolean isEmpty()Returnstrueif this stream is empty,falseotherwise.- Returns:
trueif this stream is empty,falseotherwise.
-
isNotEmpty
public final boolean isNotEmpty()Returnsfalseif this stream is empty,trueotherwise.- Returns:
falseif this stream is empty,trueotherwise.
-
uncons
Performs a reduction on this stream using the given arguments.- Parameters:
nil- The value to return if this stream is empty.cons- The function to apply to the head and tail of this stream if it is not empty.- Returns:
- A reduction on this stream.
-
foldRight
Performs a right-fold reduction across this stream. This function uses O(length) stack space.- Parameters:
f- The function to apply on each element of the stream.b- The beginning value to start the application from.- Returns:
- The final result after the right-fold reduction.
-
foldRight
Performs a right-fold reduction across this stream. This function uses O(length) stack space.- Parameters:
f- The function to apply on each element of the stream.b- The beginning value to start the application from.- Returns:
- The final result after the right-fold reduction.
-
foldRight1
Performs a right-fold reduction across this stream. This function uses O(length) stack space.- Parameters:
f- The function to apply on each element of the stream.b- The beginning value to start the application from.- Returns:
- The final result after the right-fold reduction.
-
foldRight1
Performs a right-fold reduction across this stream. This function uses O(length) stack space.- Parameters:
f- The function to apply on each element of the stream.b- The beginning value to start the application from.- Returns:
- The final result after the right-fold reduction.
-
foldLeft
Performs a left-fold reduction across this stream. This function runs in constant space.- Parameters:
f- The function to apply on each element of the stream.b- The beginning value to start the application from.- Returns:
- The final result after the left-fold reduction.
-
foldLeft
Performs a left-fold reduction across this stream. This function runs in constant space.- Parameters:
f- The function to apply on each element of the stream.b- The beginning value to start the application from.- Returns:
- The final result after the left-fold reduction.
-
foldLeft1
Takes the first 2 elements of the stream and applies the function to them, then applies the function to the result and the third element and so on.- Parameters:
f- The function to apply on each element of the stream.- Returns:
- The final result after the left-fold reduction.
-
foldLeft1
Takes the first 2 elements of the stream and applies the function to them, then applies the function to the result and the third element and so on.- Parameters:
f- The function to apply on each element of the stream.- Returns:
- The final result after the left-fold reduction.
-
orHead
-
orTail
Returns the tail of this stream if there is one or the given argument if this stream is empty.- Parameters:
as- The argument to return if this stream is empty.- Returns:
- The tail of this stream if there is one or the given argument if this stream is empty.
-
intersperse
-
map
-
map_
-
foreach
-
foreachDoEffect
-
filter
-
append
-
append
-
minus
Returns a new stream of all the items in this stream that do not appear in the given stream.- Parameters:
eq- an equality for the items of the streams.xs- a list to subtract from this stream.- Returns:
- a stream of all the items in this stream that do not appear in the given stream.
-
removeAll
-
sequence_
Turn a stream of functions into a function returning a stream.- Parameters:
fs- The stream of functions to sequence into a single function that returns a stream.- Returns:
- A function that, when given an argument, applies all the functions in the given stream to it and returns a stream of the results.
-
mapM
Maps the given function of arity-2 across this stream and returns a function that applies all the resulting functions to a given argument.- Parameters:
f- A function of arity-2- Returns:
- A function that, when given an argument, applies the given function to that argument and every element in this list.
-
bind
-
bind
Binds the given function across each element of this stream and the given stream with a final join.- Parameters:
sb- A given stream to bind the given function with.f- The function to apply to each element of this stream and the given stream.- Returns:
- A new stream after performing the map, then final join.
-
bind
Binds the given function across each element of this stream and the given stream with a final join.- Parameters:
sb- A given stream to bind the given function with.f- The function to apply to each element of this stream and the given stream.- Returns:
- A new stream after performing the map, then final join.
-
bind
Binds the given function across each element of this stream and the given streams with a final join.- Parameters:
sb- A given stream to bind the given function with.sc- A given stream to bind the given function with.f- The function to apply to each element of this stream and the given streams.- Returns:
- A new stream after performing the map, then final join.
-
bind
public final <B,C, Stream<E> bindD, E> (Stream<B> sb, Stream<C> sc, Stream<D> sd, F<A, F<B, F<C, F<D, E>>>> f) Binds the given function across each element of this stream and the given streams with a final join.- Parameters:
sb- A given stream to bind the given function with.sc- A given stream to bind the given function with.sd- A given stream to bind the given function with.f- The function to apply to each element of this stream and the given streams.- Returns:
- A new stream after performing the map, then final join.
-
bind
public final <B,C, Stream<F$> bindD, E, F$> (Stream<B> sb, Stream<C> sc, Stream<D> sd, Stream<E> se, F<A, F<B, F<C, F<D, F<E, F$>>>>> f) Binds the given function across each element of this stream and the given streams with a final join.- Parameters:
sb- A given stream to bind the given function with.sc- A given stream to bind the given function with.sd- A given stream to bind the given function with.se- A given stream to bind the given function with.f- The function to apply to each element of this stream and the given streams.- Returns:
- A new stream after performing the map, then final join.
-
bind
public final <B,C, Stream<G> bindD, E, F$, G> (Stream<B> sb, Stream<C> sc, Stream<D> sd, Stream<E> se, Stream<F$> sf, F<A, F<B, F<C, F<D, F<E, F<F$, G>>>>>> f) Binds the given function across each element of this stream and the given streams with a final join.- Parameters:
sb- A given stream to bind the given function with.sc- A given stream to bind the given function with.sd- A given stream to bind the given function with.se- A given stream to bind the given function with.sf- A given stream to bind the given function with.f- The function to apply to each element of this stream and the given streams.- Returns:
- A new stream after performing the map, then final join.
-
bind
public final <B,C, Stream<H> bindD, E, F$, G, H> (Stream<B> sb, Stream<C> sc, Stream<D> sd, Stream<E> se, Stream<F$> sf, Stream<G> sg, F<A, F<B, F<C, F<D, F<E, F<F$, F<G, H>>>>>>> f) Binds the given function across each element of this stream and the given streams with a final join.- Parameters:
sb- A given stream to bind the given function with.sc- A given stream to bind the given function with.sd- A given stream to bind the given function with.se- A given stream to bind the given function with.sf- A given stream to bind the given function with.sg- A given stream to bind the given function with.f- The function to apply to each element of this stream and the given streams.- Returns:
- A new stream after performing the map, then final join.
-
bind
public final <B,C, Stream<I> bindD, E, F$, G, H, I> (Stream<B> sb, Stream<C> sc, Stream<D> sd, Stream<E> se, Stream<F$> sf, Stream<G> sg, Stream<H> sh, F<A, F<B, F<C, F<D, F<E, F<F$, F<G, F<H, I>>>>>>>> f) Binds the given function across each element of this stream and the given streams with a final join.- Parameters:
sb- A given stream to bind the given function with.sc- A given stream to bind the given function with.sd- A given stream to bind the given function with.se- A given stream to bind the given function with.sf- A given stream to bind the given function with.sg- A given stream to bind the given function with.sh- A given stream to bind the given function with.f- The function to apply to each element of this stream and the given streams.- Returns:
- A new stream after performing the map, then final join.
-
sequence
-
sequence
-
sequence
-
sequence
-
apply
-
interleave
-
enumerationStream
-
sort
-
mergesort
-
mergePairs
-
merge
-
sort
Sort this stream according to the given ordering, using a parallel Quick Sort algorithm that uses the given parallelisation strategy.- Parameters:
o- An ordering for the elements of this stream.s- A strategy for parallelising the algorithm.- Returns:
- A new stream with the elements of this stream sorted according to the given ordering.
-
qs
-
qs_
-
flt
-
toCollection
Projects an immutable collection of this stream.- Returns:
- An immutable collection of this stream.
-
range
Returns a stream of integers from the givenfromvalue (inclusive) to the giventovalue (exclusive).- Parameters:
from- The minimum value for the stream (inclusive).to- The maximum value for the stream (exclusive).- Returns:
- A stream of integers from the given
fromvalue (inclusive) to the giventovalue (exclusive).
-
stream
Constructs a stream with the given elements.- Parameters:
as- The elements which which to construct a stream.- Returns:
- a new stream with the given elements.
-
iteratorStream
-
forever
Returns a stream that is either infinite or bounded up to the maximum value of the given iterator starting at the given value and stepping at increments of1.- Parameters:
e- The enumerator to compute successors from.from- The value to begin computing successors from.- Returns:
- A stream that is either infinite or bounded up to the maximum value of the given iterator starting at the
given value and stepping at increments of
1.
-
forever
Returns a stream that is either infinite or bounded up to the maximum value of the given iterator starting at the given value and stepping at the given increment.- Parameters:
e- The enumerator to compute successors from.from- The value to begin computing successors from.step- The increment to step.- Returns:
- A stream that is either infinite or bounded up to the maximum value of the given iterator starting at the given value and stepping at the given increment.
-
range
Returns a stream using the given enumerator from the given value to the other given value stepping at increments of1.- Parameters:
e- The enumerator to compute successors from.from- The value to begin computing successors from.to- The value to stop computing successors from.- Returns:
- A stream using the given enumerator from the given value to the other given value stepping at increments of
1.
-
range
Returns a stream using the given enumerator from the given value to the other given value stepping at the given increment.- Parameters:
e- The enumerator to compute successors from.from- The value to begin computing successors from.to- The value to stop computing successors from.step- The increment to step.- Returns:
- A stream using the given enumerator from the given value to the other given value stepping at the given increment.
-
range
-
filter
-
zapp
Zips this stream with the given stream of functions, applying each function in turn to the corresponding element in this stream to produce a new stream. If this stream and the given stream have different lengths, then the longer stream is normalised so this function never fails.- Parameters:
fs- The stream of functions to apply to this stream.- Returns:
- A new stream with a length the same as the shortest of this stream and the given stream.
-
zipWith
Zips this stream with the given stream using the given function to produce a new stream. If this stream and the given stream have different lengths, then the longer stream is normalised so this function never fails.- Parameters:
bs- The stream to zip this stream with.f- The function to zip this stream and the given stream with.- Returns:
- A new stream with a length the same as the shortest of this stream and the given stream.
-
zipWith
Zips this stream with the given stream using the given function to produce a new stream. If this stream and the given stream have different lengths, then the longer stream is normalised so this function never fails.- Parameters:
bs- The stream to zip this stream with.f- The function to zip this stream and the given stream with.- Returns:
- A new stream with a length the same as the shortest of this stream and the given stream.
-
zipWith
Partially-applied version of zipWith. Returns a function that zips a given stream with this stream using the given function.- Parameters:
f- The function to zip this stream and a given stream with.- Returns:
- A function that zips a given stream with this stream using the given function.
-
zip
Zips this stream with the given stream to produce a stream of pairs. If this stream and the given stream have different lengths, then the longer stream is normalised so this function never fails.- Parameters:
bs- The stream to zip this stream with.- Returns:
- A new stream with a length the same as the shortest of this stream and the given stream.
-
zipIndex
-
toEither
-
toOption
-
toList
-
toJavaList
-
toArray
-
toArray
-
array
-
cons
-
asString
Returns a string from the given stream of characters. The inverse of this function isfromString(String).- Parameters:
cs- The stream of characters to produce the string from.- Returns:
- A string from the given stream of characters.
-
fromString
Returns a stream of characters from the given string. The inverse of this function isasString(Stream).- Parameters:
s- The string to produce the stream of characters from.- Returns:
- A stream of characters from the given string.
-
snoc
-
snoc
-
take
-
drop
-
takeWhile
Returns the first elements of the head of this stream that match the given predicate function.- Parameters:
f- The predicate function to apply on this stream until it finds an element that does not hold, or the stream is exhausted.- Returns:
- The first elements of the head of this stream that match the given predicate function.
-
dropWhile
Removes elements from the head of this stream that do not match the given predicate function until an element is found that does match or the stream is exhausted.- Parameters:
f- The predicate function to apply through this stream.- Returns:
- The stream whose first element does not match the given predicate function.
-
span
Returns a tuple where the first element is the longest prefix of this stream that satisfies the given predicate and the second element is the remainder of the stream.- Parameters:
p- A predicate to be satisfied by a prefix of this stream.- Returns:
- A tuple where the first element is the longest prefix of this stream that satisfies the given predicate and the second element is the remainder of the stream.
-
replace
Returns a new stream resulting from replacing all elements that match the given predicate with the given element.- Parameters:
p- The predicate to match replaced elements.a- The element with which to replace elements.- Returns:
- A new stream resulting from replacing all elements that match the given predicate with the given element.
-
split
Returns a tuple where the first element is the longest prefix of this stream that does not satisfy the given predicate and the second element is the remainder of the stream.- Parameters:
p- A predicate not to be satisfied by a prefix of this stream.- Returns:
- A tuple where the first element is the longest prefix of this stream that does not satisfy the given predicate and the second element is the remainder of the stream.
-
reverse
-
last
Get the last element of this stream. Undefined for infinite streams.- Returns:
- The last element in this stream, if there is one.
-
length
public final int length()The length of this stream. This function will not terminate for an infinite stream.- Returns:
- The length of this stream.
-
index
Returns the element at the given index if it exists, fails otherwise.- Parameters:
i- The index at which to get the element to return.- Returns:
- The element at the given index if it exists, fails otherwise.
-
forall
Returnstrueif the predicate holds for all of the elements of this stream,falseotherwise (truefor the empty stream).- Parameters:
f- the predicate function to test on each element of this stream.- Returns:
trueif the predicate holds for all of the elements of this stream,falseotherwise.
-
equals
-
hashCode
-
toString
-
toStringLazy
-
toStringEager
-
exists
Returnstrueif the predicate holds for at least one of the elements of this stream,falseotherwise (falsefor the empty stream).- Parameters:
f- The predicate function to test on the elements of this stream.- Returns:
trueif the predicate holds for at least one of the elements of this stream.
-
find
Finds the first occurrence of an element that matches the given predicate or no value if no elements match.- Parameters:
f- The predicate function to test on elements of this stream.- Returns:
- The first occurrence of an element that matches the given predicate or no value if no elements match.
-
cobind
Binds the given function across the stream of substreams of this stream.- Parameters:
k- A function to bind across this stream and its substreams.- Returns:
- a new stream of the results of applying the given function to this stream and its substreams.
-
tails
-
inits
-
substreams
-
indexOf
-
sequenceW
Applies a stream of comonadic functions to this stream, returning a stream of values.- Parameters:
fs- A stream of comonadic functions to apply to this stream.- Returns:
- A new stream of the results of applying the stream of functions to this stream.
-
toFunction
-
fromFunction
-
fromFunction
Converts a function of an enumerable type to a stream of the results of that function, starting at the given index.- Parameters:
e- An enumerator for the domain of the function.f- The function to convert to a stream.i- The index into the function at which to begin the stream.- Returns:
- A new stream of the results of the given function applied to the values of the given enumerator, starting at the given value.
-
unzip
-
zipWith
-
cons
-
cons_
-
nil
-
nil_
-
isEmpty_
-
isNotEmpty_
-
single
Returns a stream of one element containing the given value.- Parameters:
a- The value for the head of the returned stream.- Returns:
- A stream of one element containing the given value.
-
single
-
cons
-
join
-
join
-
unfold
Unfolds across the given function starting at the given value to produce a stream.- Parameters:
f- The function to unfold across.b- The start value to begin the unfold.- Returns:
- A new stream that is a result of unfolding until the function does not produce a value.
-
iterateWhile
Creates a stream where the first item is calculated by applying the function on the third argument, the second item by applying the function on the previous result and so on.- Parameters:
f- The function to iterate with.p- The predicate which must be true for the next item in order to continue the iteration.a- The input to the first iteration.- Returns:
- A stream where the first item is calculated by applying the function on the third argument, the second item by applying the function on the previous result and so on.
-
iterableStream
-
arrayStream
-
repeat
Returns an infinite-length stream of the given element.- Parameters:
a- The element to repeat infinitely.- Returns:
- An infinite-length stream of the given element.
-
cycle
-
iterate
Returns a stream constructed by applying the given iteration function starting at the given value.- Parameters:
f- The iteration function.a- The value to begin iterating from.- Returns:
- A stream constructed by applying the given iteration function starting at the given value.
-
iterate
-
bind_
-
foldRight
-
sequenceEither
Sequence the given stream and collect the output on the right side of an either.- Type Parameters:
L- the type of the left valueB- the type of the right value- Parameters:
stream- the given stream- Returns:
- the either
-
sequenceEitherLeft
Sequence the given stream and collect the output on the left side of an either.- Type Parameters:
R- the type of the right valueB- the type of the left value- Parameters:
stream- the given stream- Returns:
- the either
-
sequenceEitherRight
Sequence the given stream and collect the output on the right side of an either.- Type Parameters:
L- the type of the left valueB- the type of the right value- Parameters:
stream- the given stream- Returns:
- the either
-
sequenceF
-
sequenceIO
-
sequenceList
-
sequenceOption
-
sequenceP1
-
sequenceSeq
-
sequenceSet
-
sequenceStream
-
sequenceTrampoline
Sequence the given stream and collect the output as a trampoline.- Type Parameters:
B- the type of the stream value- Parameters:
stream- the given trampoline- Returns:
- the stream
-
sequenceValidation
Sequence the given stream and collect the output as a validation.- Type Parameters:
E- the type of the failure valueB- the type of the success value- Parameters:
stream- the given stream- Returns:
- the validation
-
sequenceValidation
public static <E,B> Validation<E, Stream<B>> sequenceValidation(Semigroup<E> semigroup, Stream<Validation<E, B>> stream) Sequence the given stream and collect the output as a validation; use the given semigroup to reduce the errors.- Type Parameters:
E- the type of the failure valueB- the type of the success value- Parameters:
semigroup- the given semigroupstream- the given stream- Returns:
- the validation
-
traverseEither
Traverse this stream with the given function and collect the output on the right side of an either.- Type Parameters:
B- the type of the right valueL- the type of the left value- Parameters:
f- the given function- Returns:
- the either
-
traverseEitherLeft
Traverse this stream with the given function and collect the output on the left side of an either.- Type Parameters:
R- the type of the left valueB- the type of the right value- Parameters:
f- the given function- Returns:
- the either
-
traverseEitherRight
Traverse this stream with the given function and collect the output on the right side of an either.- Type Parameters:
L- the type of the left valueB- the type of the right value- Parameters:
f- the given function- Returns:
- the either
-
traverseF
-
traverseIO
-
traverseList
-
traverseOption
-
traverseP1
-
traverseSeq
-
traverseSet
-
traverseStream
-
traverseTrampoline
Traverse this stream with the given function and collect the output as a trampoline.- Type Parameters:
B- the type of the trampoline value- Parameters:
f- the given function- Returns:
- the trampoline
-
traverseValidation
Traverse this stream with the given function and collect the output as a validation.- Type Parameters:
E- the type of the failure valueB- the type of the success value- Parameters:
f- the given function- Returns:
- the validation
-
traverseValidation
public final <E,B> Validation<E, Stream<B>> traverseValidation(Semigroup<E> semigroup, F<A, Validation<E, B>> f) Traverse this stream with the given function and collect the output as a validation; use the given semigroup to reduce the errors.- Type Parameters:
E- the type of the failure valueB- the type of the success value- Parameters:
semigroup- the given semigroupf- the given function- Returns:
- the validation
-