Class BaseStreamEx<T,S extends BaseStream<T,S>,SPLTR extends Spliterator<T>,B extends BaseStreamEx<T,S,SPLTR,B>>
- All Implemented Interfaces:
AutoCloseable
,BaseStream<T,
S>
- Direct Known Subclasses:
AbstractStreamEx
,DoubleStreamEx
,IntStreamEx
,LongStreamEx
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final String
(package private) StreamContext
(package private) SPLTR
private S
-
Constructor Summary
ConstructorsConstructorDescriptionBaseStreamEx
(SPLTR spliterator, StreamContext context) BaseStreamEx
(S stream, StreamContext context) -
Method Summary
Modifier and TypeMethodDescriptionabstract <U> U
Applies the supplied function to this stream and returns the result of the function.void
close()
(package private) abstract S
boolean
parallel()
parallel
(ForkJoinPool fjp) Returns an equivalent stream that is parallel and bound to the suppliedForkJoinPool
.(package private) final S
stream()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.stream.BaseStream
iterator
-
Field Details
-
CONSUMED_MESSAGE
- See Also:
-
stream
-
spliterator
SPLTR extends Spliterator<T> spliterator -
context
StreamContext context
-
-
Constructor Details
-
BaseStreamEx
BaseStreamEx(S stream, StreamContext context) -
BaseStreamEx
BaseStreamEx(SPLTR spliterator, StreamContext context)
-
-
Method Details
-
createStream
-
stream
-
spliterator
- Specified by:
spliterator
in interfaceBaseStream<T,
S extends BaseStream<T, S>>
-
isParallel
public boolean isParallel()- Specified by:
isParallel
in interfaceBaseStream<T,
S extends BaseStream<T, S>>
-
sequential
- Specified by:
sequential
in interfaceBaseStream<T,
S extends BaseStream<T, S>>
-
parallel
If this stream was created using
parallel(ForkJoinPool)
, the new stream forgets about supplied customForkJoinPool
and its terminal operation will be executed in common pool.- Specified by:
parallel
in interfaceBaseStream<T,
S extends BaseStream<T, S>>
-
parallel
Returns an equivalent stream that is parallel and bound to the suppliedForkJoinPool
.This is an intermediate operation.
The terminal operation of this stream or any derived stream (except the streams created via
parallel()
orsequential()
methods) will be executed inside the suppliedForkJoinPool
. If current thread does not belong to that pool, it will wait till calculation finishes.- Parameters:
fjp
- aForkJoinPool
to submit the stream operation to.- Returns:
- a parallel stream bound to the supplied
ForkJoinPool
- Since:
- 0.2.0
-
unordered
- Specified by:
unordered
in interfaceBaseStream<T,
S extends BaseStream<T, S>>
-
onClose
- Specified by:
onClose
in interfaceBaseStream<T,
S extends BaseStream<T, S>>
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceBaseStream<T,
S extends BaseStream<T, S>>
-
chain
Applies the supplied function to this stream and returns the result of the function.This method can be used to add more functionality in the fluent style. For example, consider user-defined static method
batches(stream, n)
which breaks the stream into batches of given length. Normally you would writebatches(StreamEx.of(input).map(...), 10).filter(...)
. Using thechain()
method you can write in more fluent manner:StreamEx.of(input).map(...).chain(s -> batches(s, 10)).filter(...)
.You could even go further and define a method which returns a function like
<T> UnaryOperator<StreamEx<T>> batches(int n)
and use it like this:StreamEx.of(input).map(...).chain(batches(10)).filter(...)
.- Type Parameters:
U
- the type of the function result.- Parameters:
mapper
- function to invoke.- Returns:
- the result of the function invocation.
- Since:
- 0.5.4
-