public abstract class Stream<A>
extends java.lang.Object
implements java.lang.Iterable<A>
Modifier and Type | Method and Description |
---|---|
Stream<A> |
append(F0<Stream<A>> as)
Appends the given stream to this stream.
|
Stream<A> |
append(Stream<A> as)
Appends the given stream to this stream.
|
<B> Stream<B> |
apply(Stream<F<A,B>> sf)
Performs function application within a stream (applicative functor pattern).
|
A[] |
array(java.lang.Class<A[]> c)
Returns an array from this stream.
|
static <A> Stream<A> |
arrayStream(A... as) |
static java.lang.String |
asString(Stream<java.lang.Character> cs)
Returns a string from the given stream of characters.
|
static <A,B> F<F<A,Stream<B>>,F<Stream<A>,Stream<B>>> |
bind_()
A first-class version of the bind function.
|
<B> Stream<B> |
bind(F<A,Stream<B>> f)
Binds the given function across each element of this stream with a final join.
|
<B,C> Stream<C> |
bind(Stream<B> sb,
F<A,F<B,C>> f)
Binds the given function across each element of this stream and the given stream with a final
join.
|
<B,C> Stream<C> |
bind(Stream<B> sb,
F2<A,B,C> f)
Binds the given function across each element of this stream and the given stream with a final
join.
|
<B,C,D> Stream<D> |
bind(Stream<B> sb,
Stream<C> sc,
F<A,F<B,F<C,D>>> f)
Binds the given function across each element of this stream and the given streams with a final
join.
|
<B,C,D,E> Stream<E> |
bind(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.
|
<B,C,D,E,F$> |
bind(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.
|
<B,C,D,E,F$,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.
|
<B,C,D,E,F$,G,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.
|
<B,C,D,E,F$,G,H,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.
|
<B> Stream<B> |
cobind(F<Stream<A>,B> k)
Binds the given function across the stream of substreams of this stream.
|
static <A> F<A,F<Stream<A>,Stream<A>>> |
cons_()
Returns a function that prepends (cons) an element to a stream to produce a new stream.
|
static <A> F<A,F<P1<Stream<A>>,Stream<A>>> |
cons()
Returns a function that prepends (cons) an element to a stream to produce a new stream.
|
Stream<A> |
cons(A a)
Prepends (cons) the given element to this stream to product a new stream.
|
static <A> Stream<A> |
cons(A head,
F0<Stream<A>> tail)
Prepends the given head element to the given tail element to produce a new stream.
|
static <A> Stream<A> |
cycle(Stream<A> as)
Returns an infinite-length stream of the given elements cycling.
|
Stream<A> |
drop(int i)
Drops the given number of elements from the head of this stream if they are available.
|
Stream<A> |
dropWhile(F<A,java.lang.Boolean> f)
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(java.util.Enumeration<A> e) |
boolean |
equals(java.lang.Object other) |
boolean |
exists(F<A,java.lang.Boolean> f)
Returns
true if the predicate holds for at least one of the elements of this
stream, false otherwise (false for the empty stream). |
static <A> F<F<A,java.lang.Boolean>,F<Stream<A>,Stream<A>>> |
filter()
Returns a first-class version of the filter function.
|
Stream<A> |
filter(F<A,java.lang.Boolean> f)
Filters elements from this stream by returning only elements which produce
true
when the given function is applied to them. |
Option<A> |
find(F<A,java.lang.Boolean> f)
Finds the first occurrence of an element that matches the given predicate or no value if no
elements match.
|
<B> B |
foldLeft(F<B,F<A,B>> f,
B b)
Performs a left-fold reduction across this stream.
|
<B> B |
foldLeft(F2<B,A,B> f,
B b)
Performs a left-fold reduction across this stream.
|
A |
foldLeft1(F<A,F<A,A>> f)
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.
|
A |
foldLeft1(F2<A,A,A> f)
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.
|
static <A,B> F<F<A,F<P1<B>,B>>,F<B,F<Stream<A>,B>>> |
foldRight()
A first-class version of the foldRight function.
|
<B> B |
foldRight(F<A,F<P1<B>,B>> f,
B b)
Performs a right-fold reduction across this stream.
|
<B> B |
foldRight(F2<A,P1<B>,B> f,
B b)
Performs a right-fold reduction across this stream.
|
<B> B |
foldRight1(F<A,F<B,B>> f,
B b)
Performs a right-fold reduction across this stream.
|
<B> B |
foldRight1(F2<A,B,B> f,
B b)
Performs a right-fold reduction across this stream.
|
boolean |
forall(F<A,java.lang.Boolean> f)
Returns
true if the predicate holds for all of the elements of this stream,
false otherwise (true for the empty stream). |
Unit |
foreach(F<A,Unit> f)
Performs a side-effect for each element of this stream.
|
void |
foreachDoEffect(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 of
1 . |
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.
|
static Stream<java.lang.Character> |
fromString(java.lang.String s)
Returns a stream of characters from the given string.
|
int |
hashCode() |
abstract A |
head()
The first element of the stream or fails for the empty stream.
|
A |
index(int i)
Returns the element at the given index if it exists, fails otherwise.
|
Option<java.lang.Integer> |
indexOf(F<A,java.lang.Boolean> p)
Returns the position of the first element matching the given predicate, if any.
|
Stream<Stream<A>> |
inits()
Returns a stream of all prefixes of this stream.
|
Stream<A> |
interleave(Stream<A> as)
Interleaves the given stream with this stream to produce a new stream.
|
Stream<A> |
intersperse(A a)
Intersperses the given value between each two elements of the stream.
|
static <A> F<Stream<A>,java.lang.Boolean> |
isEmpty_()
Returns a function that determines whether a given stream is empty.
|
boolean |
isEmpty()
Returns
true if this stream is empty, false otherwise. |
static <A> F<Stream<A>,java.lang.Boolean> |
isNotEmpty_()
Returns a function that determines whether a given stream is not empty.
|
boolean |
isNotEmpty()
Returns
false if this stream is empty, true otherwise. |
static <A> Stream<A> |
iterableStream(java.lang.Iterable<A> i)
Takes the given iterable to a stream.
|
static <A> F<F<A,A>,F<A,Stream<A>>> |
iterate()
A first-class version of the iterate function.
|
static <A> Stream<A> |
iterate(F<A,A> f,
A 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,java.lang.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.
|
java.util.Iterator<A> |
iterator()
Returns an iterator for this stream.
|
static <A> Stream<A> |
iteratorStream(java.util.Iterator<A> it)
Constructs a stream with the given elements in the Iterator.
|
static <A> F<Stream<Stream<A>>,Stream<A>> |
join()
A first-class version of join
|
static <A> Stream<A> |
join(Stream<Stream<A>> o)
Joins the given stream of streams by concatenation.
|
A |
last()
Get the last element of this stream.
|
int |
length()
The length of this stream.
|
static <A,B> F<F<A,B>,F<Stream<A>,Stream<B>>> |
map_()
Provides a first-class version of the map function.
|
<B> Stream<B> |
map(F<A,B> f)
Maps the given function across this stream.
|
<B,C> F<B,Stream<C>> |
mapM(F<A,F<B,C>> f)
Maps the given function of arity-2 across this stream and returns a function that applies all the resulting
functions to a given argument.
|
Stream<A> |
minus(Equal<A> eq,
Stream<A> xs)
Returns a new stream of all the items in this stream that do not appear in the given stream.
|
static <A> P1<Stream<A>> |
nil_()
Returns an empty stream.
|
static <A> Stream<A> |
nil()
Returns an empty stream.
|
A |
orHead(F0<A> a)
Returns the head of this stream if there is one or the given argument if this stream is empty.
|
P1<Stream<A>> |
orTail(F0<Stream<A>> as)
Returns the tail of this stream if there is one or the given argument if this stream is empty.
|
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 of
1 . |
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.
|
static Stream<java.lang.Integer> |
range(int from)
Returns an infinite stream of integers from the given
from value (inclusive). |
static Stream<java.lang.Integer> |
range(int from,
long to)
Returns a stream of integers from the given
from value (inclusive) to the given
to value (exclusive). |
Stream<A> |
removeAll(F<A,java.lang.Boolean> f)
Filters elements from this stream by returning only elements which produce
false when
the given function is applied to them. |
static <A> Stream<A> |
repeat(A a)
Returns an infinite-length stream of the given element.
|
Stream<A> |
replace(F<A,java.lang.Boolean> p,
A a)
Returns a new stream resulting from replacing all elements that match the given predicate with the given element.
|
Stream<A> |
reverse()
Reverse this stream in constant stack space.
|
static <A,B> F<B,Stream<A>> |
sequence_(Stream<F<B,A>> fs)
Turn a stream of functions into a function returning a stream.
|
static <A> Stream<P1<A>> |
sequence(F0<Stream<A>> p)
Sequence through the Stream monad.
|
static <A> Stream<IO<A>> |
sequence(IO<Stream<A>> io)
Sequence through the Stream monad.
|
static <A> Stream<Option<A>> |
sequence(Option<Stream<A>> o)
Sequence through the Stream monad.
|
<B> Stream<B> |
sequence(Stream<B> bs)
Performs a bind across each stream element, but ignores the element value each time.
|
<B> Stream<B> |
sequenceW(Stream<F<Stream<A>,B>> fs)
Applies a stream of comonadic functions to this stream, returning a stream of values.
|
static <A> F<A,Stream<A>> |
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.
|
Stream<A> |
snoc(A a)
Append the given element to this stream to product a new stream.
|
Stream<A> |
snoc(F0<A> a)
Append the given element to this stream to produce a new stream.
|
Stream<A> |
sort(Ord<A> o)
Sort this stream according to the given ordering.
|
Stream<A> |
sort(Ord<A> o,
Strategy<Unit> s)
Sort this stream according to the given ordering, using a parallel Quick Sort algorithm that uses the given
parallelisation strategy.
|
P2<Stream<A>,Stream<A>> |
span(F<A,java.lang.Boolean> p)
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.
|
P2<Stream<A>,Stream<A>> |
split(F<A,java.lang.Boolean> p)
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.
|
<B> B |
stream(B nil,
F<A,F<P1<Stream<A>>,B>> cons)
Deprecated.
As of release 4.5, use
uncons(B, fj.F<A, fj.F<fj.P1<fj.data.Stream<A>>, B>>) |
static <A> Stream<A> |
stream(java.lang.Iterable<A> it)
Deprecated.
As of release 4.5, use
iterableStream(Iterable) |
static <A> Stream<A> |
stream(java.util.Iterator<A> it)
Deprecated.
As of release 4.5, use
iteratorStream(Iterator) |
Stream<Stream<A>> |
substreams()
Returns a stream of all infixes of this stream.
|
abstract P1<Stream<A>> |
tail()
The stream without the first element or fails for the empty stream.
|
Stream<Stream<A>> |
tails()
Returns a stream of the suffixes of this stream.
|
Stream<A> |
take(int n)
Returns the first
n elements from the head of this stream. |
Stream<A> |
takeWhile(F<A,java.lang.Boolean> f)
Returns the first elements of the head of this stream that match the given predicate function.
|
Array<A> |
toArray()
Returns a array projection of this stream.
|
Array<A> |
toArray(java.lang.Class<A[]> c)
Returns a array projection of this stream.
|
java.util.Collection<A> |
toCollection()
Projects an immutable collection of this stream.
|
<X> Either<X,A> |
toEither(F0<X> x)
Returns an either projection of this stream; the given argument in
Left if empty,
or the first element in Right . |
F<java.lang.Integer,A> |
toFunction()
Converts this stream to a function of natural numbers.
|
A[] |
toJavaArray()
Deprecated.
As of release 4.6, use
array(Class) . |
java.util.List<A> |
toJavaList()
Returns a java.util.List projection of this stream.
|
List<A> |
toList()
Returns a list projection of this stream.
|
Option<A> |
toOption()
Returns an option projection of this stream;
None if empty, or the first element
in Some . |
java.lang.String |
toString() |
java.lang.String |
toStringEager() |
java.lang.String |
toStringLazy() |
<B> IO<Stream<B>> |
traverseIO(F<A,IO<B>> f)
Traversable instance of Stream for IO.
|
<B> Option<Stream<B>> |
traverseOption(F<A,Option<B>> f)
Traversable instance of Stream for Option.
|
<B> B |
uncons(B nil,
F<A,F<P1<Stream<A>>,B>> cons)
Performs a reduction on this stream using the given arguments.
|
static <A,B> Stream<A> |
unfold(F<B,Option<P2<A,B>>> f,
B b)
Unfolds across the given function starting at the given value to produce a stream.
|
static <A,B> P2<Stream<A>,Stream<B>> |
unzip(Stream<P2<A,B>> xs)
Transforms a stream of pairs into a stream of first components and a stream of second components.
|
<B> Stream<B> |
zapp(Stream<F<A,B>> fs)
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.
|
<B> Stream<P2<A,B>> |
zip(Stream<B> bs)
Zips this stream with the given stream to produce a stream of pairs.
|
Stream<P2<A,java.lang.Integer>> |
zipIndex()
Zips this stream with the index of its element as a pair.
|
static <A,B,C> F<Stream<A>,F<Stream<B>,F<F<A,F<B,C>>,Stream<C>>>> |
zipWith()
A first-class version of the zipWith function.
|
<B,C> F<Stream<B>,Stream<C>> |
zipWith(F<A,F<B,C>> f)
Partially-applied version of zipWith.
|
<B,C> Stream<C> |
zipWith(Stream<B> bs,
F<A,F<B,C>> f)
Zips this stream with the given stream using the given function to produce a new stream.
|
<B,C> Stream<C> |
zipWith(Stream<B> bs,
F2<A,B,C> f)
Zips this stream with the given stream using the given function to produce a new stream.
|
public final java.util.Iterator<A> iterator()
for
-each loop.iterator
in interface java.lang.Iterable<A>
public abstract A head()
public abstract P1<Stream<A>> tail()
public final boolean isEmpty()
true
if this stream is empty, false
otherwise.true
if this stream is empty, false
otherwise.public final boolean isNotEmpty()
false
if this stream is empty, true
otherwise.false
if this stream is empty, true
otherwise.@Deprecated public final <B> B stream(B nil, F<A,F<P1<Stream<A>>,B>> cons)
uncons(B, fj.F<A, fj.F<fj.P1<fj.data.Stream<A>>, B>>)
uncons(B, fj.F<A, fj.F<fj.P1<fj.data.Stream<A>>, B>>)
.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.public final <B> B uncons(B nil, F<A,F<P1<Stream<A>>,B>> cons)
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.public final <B> B foldRight(F<A,F<P1<B>,B>> f, B b)
f
- The function to apply on each element of the stream.b
- The beginning value to start the application from.public final <B> B foldRight(F2<A,P1<B>,B> f, B b)
f
- The function to apply on each element of the stream.b
- The beginning value to start the application from.public final <B> B foldRight1(F<A,F<B,B>> f, B b)
f
- The function to apply on each element of the stream.b
- The beginning value to start the application from.public final <B> B foldRight1(F2<A,B,B> f, B b)
f
- The function to apply on each element of the stream.b
- The beginning value to start the application from.public final <B> B foldLeft(F<B,F<A,B>> f, B b)
f
- The function to apply on each element of the stream.b
- The beginning value to start the application from.public final <B> B foldLeft(F2<B,A,B> f, B b)
f
- The function to apply on each element of the stream.b
- The beginning value to start the application from.public final A foldLeft1(F2<A,A,A> f)
f
- The function to apply on each element of the stream.public final A foldLeft1(F<A,F<A,A>> f)
f
- The function to apply on each element of the stream.public final A orHead(F0<A> a)
a
- The argument to return if this stream is empty.public final P1<Stream<A>> orTail(F0<Stream<A>> as)
as
- The argument to return if this stream is empty.public final Stream<A> intersperse(A a)
a
- The value to intersperse between values of the stream.public final <B> Stream<B> map(F<A,B> f)
f
- The function to map across this stream.public static <A,B> F<F<A,B>,F<Stream<A>,Stream<B>>> map_()
public final Unit foreach(F<A,Unit> f)
f
- The side-effect to perform for the given element.public final void foreachDoEffect(Effect1<A> f)
f
- The side-effect to perform for the given element.public final Stream<A> filter(F<A,java.lang.Boolean> f)
true
when the given function is applied to them.f
- The predicate function to filter on.public final Stream<A> append(Stream<A> as)
as
- The stream to append to this one.public final Stream<A> append(F0<Stream<A>> as)
as
- The stream to append to this one.public final Stream<A> minus(Equal<A> eq, Stream<A> xs)
eq
- an equality for the items of the streams.xs
- a list to subtract from this stream.public final Stream<A> removeAll(F<A,java.lang.Boolean> f)
false
when
the given function is applied to them.f
- The predicate function to filter on.public static <A,B> F<B,Stream<A>> sequence_(Stream<F<B,A>> fs)
fs
- The stream of functions to sequence into a single function that returns a stream.public final <B,C> F<B,Stream<C>> mapM(F<A,F<B,C>> f)
f
- A function of arity-2public final <B> Stream<B> bind(F<A,Stream<B>> f)
f
- The function to apply to each element of this stream.public final <B,C> Stream<C> bind(Stream<B> sb, F<A,F<B,C>> f)
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.public final <B,C> Stream<C> bind(Stream<B> sb, F2<A,B,C> f)
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.public final <B,C,D> Stream<D> bind(Stream<B> sb, Stream<C> sc, F<A,F<B,F<C,D>>> f)
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.public final <B,C,D,E> Stream<E> bind(Stream<B> sb, Stream<C> sc, Stream<D> sd, F<A,F<B,F<C,F<D,E>>>> f)
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.public final <B,C,D,E,F$> Stream<F$> bind(Stream<B> sb, Stream<C> sc, Stream<D> sd, Stream<E> se, F<A,F<B,F<C,F<D,F<E,F$>>>>> f)
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.public 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)
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.public 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)
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.public 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)
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.public final <B> Stream<B> sequence(Stream<B> bs)
bs
- The stream to apply in the final join.public static <A> Stream<IO<A>> sequence(IO<Stream<A>> io)
io
- The IO stream to sequence.public static <A> Stream<P1<A>> sequence(F0<Stream<A>> p)
p
- The lazy stream to sequence.public static <A> Stream<Option<A>> sequence(Option<Stream<A>> o)
o
- The optional stream to sequence.public final <B> Stream<B> apply(Stream<F<A,B>> sf)
sf
- The stream of functions to apply.public final Stream<A> interleave(Stream<A> as)
as
- The stream to interleave this stream with.public static <A> Stream<A> enumerationStream(java.util.Enumeration<A> e)
public final Stream<A> sort(Ord<A> o)
o
- An ordering for the elements of this stream.public final Stream<A> sort(Ord<A> o, Strategy<Unit> s)
o
- An ordering for the elements of this stream.s
- A strategy for parallelising the algorithm.public final java.util.Collection<A> toCollection()
public static Stream<java.lang.Integer> range(int from, long to)
from
value (inclusive) to the given
to
value (exclusive).from
- The minimum value for the stream (inclusive).to
- The maximum value for the stream (exclusive).from
value (inclusive) to the given
to
value (exclusive).@SafeVarargs public static <A> Stream<A> stream(A... as)
as
- The elements which which to construct a stream.@Deprecated public static <A> Stream<A> stream(java.lang.Iterable<A> it)
iterableStream(Iterable)
iterableStream(Iterable)
.@Deprecated public static <A> Stream<A> stream(java.util.Iterator<A> it)
iteratorStream(Iterator)
iteratorStream(Iterator)
.public static <A> Stream<A> iteratorStream(java.util.Iterator<A> it)
public static <A> Stream<A> forever(Enumerator<A> e, A from)
1
.e
- The enumerator to compute successors from.from
- The value to begin computing successors from.1
.public static <A> Stream<A> forever(Enumerator<A> e, A from, long step)
e
- The enumerator to compute successors from.from
- The value to begin computing successors from.step
- The increment to step.public static <A> Stream<A> range(Enumerator<A> e, A from, A to)
1
.e
- The enumerator to compute successors from.from
- The value to begin computing successors from.to
- The value to stop computing successors from.1
.public static <A> Stream<A> range(Enumerator<A> e, A from, A to, long step)
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.public static Stream<java.lang.Integer> range(int from)
from
value (inclusive).from
- The minimum value for the stream (inclusive).from
value (inclusive).public static <A> F<F<A,java.lang.Boolean>,F<Stream<A>,Stream<A>>> filter()
public final <B> Stream<B> zapp(Stream<F<A,B>> fs)
fs
- The stream of functions to apply to this stream.public final <B,C> Stream<C> zipWith(Stream<B> bs, F<A,F<B,C>> f)
bs
- The stream to zip this stream with.f
- The function to zip this stream and the given stream with.public final <B,C> Stream<C> zipWith(Stream<B> bs, F2<A,B,C> f)
bs
- The stream to zip this stream with.f
- The function to zip this stream and the given stream with.public final <B,C> F<Stream<B>,Stream<C>> zipWith(F<A,F<B,C>> f)
f
- The function to zip this stream and a given stream with.public final <B> Stream<P2<A,B>> zip(Stream<B> bs)
bs
- The stream to zip this stream with.public final Stream<P2<A,java.lang.Integer>> zipIndex()
public final <X> Either<X,A> toEither(F0<X> x)
Left
if empty,
or the first element in Right
.x
- The value to return in left if this stream is empty.public final Option<A> toOption()
None
if empty, or the first element
in Some
.@Deprecated public final A[] toJavaArray()
array(Class)
.public final List<A> toList()
public final java.util.List<A> toJavaList()
public final Array<A> toArray()
public final Array<A> toArray(java.lang.Class<A[]> c)
c
- The class type of the array to return.public final A[] array(java.lang.Class<A[]> c)
c
- The class type of the array to return.public final Stream<A> cons(A a)
a
- The element to prepend.public static java.lang.String asString(Stream<java.lang.Character> cs)
fromString(String)
.cs
- The stream of characters to produce the string from.public static Stream<java.lang.Character> fromString(java.lang.String s)
asString(Stream)
.s
- The string to produce the stream of characters from.public final Stream<A> snoc(A a)
a
- The element to append.public final Stream<A> snoc(F0<A> a)
a
- The element to append.public final Stream<A> take(int n)
n
elements from the head of this stream.n
- The number of elements to take from this stream.n
elements from the head of this stream.public final Stream<A> drop(int i)
i
- The number of elements to drop from the head of this stream.public final Stream<A> takeWhile(F<A,java.lang.Boolean> f)
f
- The predicate function to apply on this stream until it finds an element that does not
hold, or the stream is exhausted.public final <B> IO<Stream<B>> traverseIO(F<A,IO<B>> f)
public final <B> Option<Stream<B>> traverseOption(F<A,Option<B>> f)
public final Stream<A> dropWhile(F<A,java.lang.Boolean> f)
f
- The predicate function to apply through this stream.public final P2<Stream<A>,Stream<A>> span(F<A,java.lang.Boolean> p)
p
- A predicate to be satisfied by a prefix of this stream.public final Stream<A> replace(F<A,java.lang.Boolean> p, A a)
p
- The predicate to match replaced elements.a
- The element with which to replace elements.public final P2<Stream<A>,Stream<A>> split(F<A,java.lang.Boolean> p)
p
- A predicate not to be satisfied by a prefix of this stream.public final Stream<A> reverse()
public final A last()
public final int length()
public final A index(int i)
i
- The index at which to get the element to return.public final boolean forall(F<A,java.lang.Boolean> f)
true
if the predicate holds for all of the elements of this stream,
false
otherwise (true
for the empty stream).f
- the predicate function to test on each element of this stream.true
if the predicate holds for all of the elements of this stream,
false
otherwise.public final boolean equals(java.lang.Object other)
equals
in class java.lang.Object
public final int hashCode()
hashCode
in class java.lang.Object
public final java.lang.String toString()
toString
in class java.lang.Object
public final java.lang.String toStringLazy()
public final java.lang.String toStringEager()
public final boolean exists(F<A,java.lang.Boolean> f)
true
if the predicate holds for at least one of the elements of this
stream, false
otherwise (false
for the empty stream).f
- The predicate function to test on the elements of this stream.true
if the predicate holds for at least one of the elements of this
stream.public final Option<A> find(F<A,java.lang.Boolean> f)
f
- The predicate function to test on elements of this stream.public final <B> Stream<B> cobind(F<Stream<A>,B> k)
k
- A function to bind across this stream and its substreams.public final Stream<Stream<A>> tails()
public final Stream<Stream<A>> inits()
public final Stream<Stream<A>> substreams()
public final Option<java.lang.Integer> indexOf(F<A,java.lang.Boolean> p)
p
- A predicate to match.public final <B> Stream<B> sequenceW(Stream<F<Stream<A>,B>> fs)
fs
- A stream of comonadic functions to apply to this stream.public final F<java.lang.Integer,A> toFunction()
public static <A> Stream<A> fromFunction(F<Natural,A> f)
f
- The function to convert to a stream.public static <A,B> Stream<A> fromFunction(Enumerator<B> e, F<B,A> f, B i)
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.public static <A,B> P2<Stream<A>,Stream<B>> unzip(Stream<P2<A,B>> xs)
xs
- The stream of pairs to transform.public static <A,B,C> F<Stream<A>,F<Stream<B>,F<F<A,F<B,C>>,Stream<C>>>> zipWith()
public static <A> F<A,F<P1<Stream<A>>,Stream<A>>> cons()
public static <A> F<A,F<Stream<A>,Stream<A>>> cons_()
public static <A> Stream<A> nil()
public static <A> F<Stream<A>,java.lang.Boolean> isEmpty_()
public static <A> F<Stream<A>,java.lang.Boolean> isNotEmpty_()
public static <A> Stream<A> single(A a)
a
- The value for the head of the returned stream.public static <A> F<A,Stream<A>> single()
public static <A> Stream<A> cons(A head, F0<Stream<A>> tail)
head
- The element to prepend.tail
- The stream to prepend to.public static <A> Stream<A> join(Stream<Stream<A>> o)
o
- The stream of streams to join.public static <A> F<Stream<Stream<A>>,Stream<A>> join()
public static <A,B> Stream<A> unfold(F<B,Option<P2<A,B>>> f, B b)
f
- The function to unfold across.b
- The start value to begin the unfold.public static <A> Stream<A> iterateWhile(F<A,A> f, F<A,java.lang.Boolean> p, A a)
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.public static <A> Stream<A> iterableStream(java.lang.Iterable<A> i)
i
- The iterable to take to a stream.@SafeVarargs public static <A> Stream<A> arrayStream(A... as)
public static <A> Stream<A> repeat(A a)
a
- The element to repeat infinitely.public static <A> Stream<A> cycle(Stream<A> as)
as
- The elements to cycle infinitely. This must not be empty.public static <A> Stream<A> iterate(F<A,A> f, A a)
f
- The iteration function.a
- The value to begin iterating from.public static <A> F<F<A,A>,F<A,Stream<A>>> iterate()
public static <A,B> F<F<A,Stream<B>>,F<Stream<A>,Stream<B>>> bind_()