public abstract class IntStream
extends java.lang.Object
int
primitive specialization of
Stream
.
The following example illustrates an aggregate operation using
Stream
and IntStream
, computing the sum of the weights of the
red widgets:
int sum = widgets.stream()
.filter(w -> w.getColor() == RED)
.mapToInt(w -> w.getWeight())
.sum();
See the class documentation for Stream
and the package documentation
for java.util.stream for additional
specification of streams, stream operations, stream pipelines, and
parallelism.Stream
,
java.util.streamModifier and Type | Class and Description |
---|---|
static class |
IntStream.IntStreamEx |
BaseStream.Splitor
Modifier and Type | Method and Description |
---|---|
<R> R |
__(Function<? super IntStream,R> transfer) |
abstract DoubleStream |
asDoubleStream()
Returns a
DoubleStream consisting of the elements of this stream,
converted to double . |
abstract FloatStream |
asFloatStream()
Returns a
FloatStream consisting of the elements of this stream,
converted to double . |
abstract LongStream |
asLongStream()
Returns a
LongStream consisting of the elements of this stream,
converted to long . |
abstract OptionalDouble |
average()
Returns an
OptionalDouble describing the arithmetic mean of elements of
this stream, or an empty optional if this stream is empty. |
abstract Stream<java.lang.Integer> |
boxed()
Returns a
Stream consisting of the elements of this stream,
each boxed to an Integer . |
S |
carry(C action)
Same as
peek |
void |
close()
Closes this stream, causing all close handlers for this stream pipeline
to be called.
|
abstract IntStream |
collapse(IntBiPredicate collapsible,
IntBiFunction<java.lang.Integer> mergeFunction)
Merge series of adjacent elements which satisfy the given predicate using
the merger function and return a new stream.
|
abstract <R> R |
collect(Supplier<R> supplier,
ObjIntConsumer<R> accumulator) |
abstract <R> R |
collect(Supplier<R> supplier,
ObjIntConsumer<R> accumulator,
BiConsumer<R,R> combiner)
Performs a mutable
reduction operation on the elements of this stream.
|
static IntStream |
concat(java.util.Collection<? extends IntStream> c) |
static IntStream |
concat(int[]... a) |
static IntStream |
concat(IntIterator... a) |
static IntStream |
concat(IntStream... a) |
static IntStream |
empty() |
OT |
findAny(P predicate)
Returns an
Optional describing some element of the stream, or an
empty Optional if the stream is empty. |
abstract IntStream |
flatArray(IntFunction<int[]> mapper) |
abstract IntStream |
flatMap(IntFunction<? extends IntStream> mapper)
Returns a stream consisting of the results of replacing each element of
this stream with the contents of a mapped stream produced by applying
the provided mapping function to each element.
|
abstract ByteStream |
flatMapToByte(IntFunction<? extends ByteStream> mapper) |
abstract CharStream |
flatMapToChar(IntFunction<? extends CharStream> mapper) |
abstract DoubleStream |
flatMapToDouble(IntFunction<? extends DoubleStream> mapper) |
abstract FloatStream |
flatMapToFloat(IntFunction<? extends FloatStream> mapper) |
abstract LongStream |
flatMapToLong(IntFunction<? extends LongStream> mapper) |
abstract <T> Stream<T> |
flatMapToObj(IntFunction<? extends Stream<T>> mapper) |
abstract ShortStream |
flatMapToShort(IntFunction<? extends ShortStream> mapper) |
static IntStream |
from(byte... a) |
static IntStream |
from(byte[] a,
int fromIndex,
int toIndex) |
static IntStream |
from(char... a) |
static IntStream |
from(char[] a,
int fromIndex,
int toIndex) |
static IntStream |
from(short... a) |
static IntStream |
from(short[] a,
int fromIndex,
int toIndex) |
static IntStream |
generate(IntSupplier s) |
abstract OptionalInt |
head()
Head and tail should be used by pair.
|
abstract IntStream |
head2()
Head2 and tail2 should be used by pair.
|
abstract Pair<OptionalInt,IntStream> |
headAndTail() |
abstract Pair<IntStream,OptionalInt> |
headAndTail2() |
boolean |
isParallel()
Returns whether this stream, if a terminal operation were to be executed,
would execute in parallel.
|
static IntStream |
iterate(int seed,
IntPredicate hasNext,
IntUnaryOperator f) |
static IntStream |
iterate(int seed,
IntUnaryOperator f) |
static IntStream |
iterate(int seed,
Supplier<java.lang.Boolean> hasNext,
IntUnaryOperator f) |
static IntStream |
iterate(Supplier<java.lang.Boolean> hasNext,
IntSupplier next) |
IntIterator |
iterator()
Returns an iterator for the elements of this stream.
|
abstract OptionalInt |
kthLargest(int k) |
abstract IntStream |
map(IntUnaryOperator mapper)
Returns a stream consisting of the results of applying the given
function to the elements of this stream.
|
abstract ByteStream |
mapToByte(IntToByteFunction mapper) |
abstract CharStream |
mapToChar(IntToCharFunction mapper) |
abstract DoubleStream |
mapToDouble(IntToDoubleFunction mapper)
Returns a
DoubleStream consisting of the results of applying the
given function to the elements of this stream. |
abstract FloatStream |
mapToFloat(IntToFloatFunction mapper)
Returns a
FloatStream consisting of the results of applying the
given function to the elements of this stream. |
abstract LongStream |
mapToLong(IntToLongFunction mapper)
Returns a
LongStream consisting of the results of applying the
given function to the elements of this stream. |
abstract <U> Stream<U> |
mapToObj(IntFunction<? extends U> mapper)
Returns an object-valued
Stream consisting of the results of
applying the given function to the elements of this stream. |
abstract ShortStream |
mapToShort(IntToShortFunction mapper) |
abstract OptionalInt |
max()
Returns an
OptionalInt describing the maximum element of this
stream, or an empty optional if this stream is empty. |
int |
maxThreadNum()
Return the underlying
maxThreadNum if the stream is parallel, otherwise 1 is returned. |
S |
maxThreadNum(int maxThreadNum)
Returns a parallel stream with the specified
maxThreadNum . |
static IntStream |
merge(java.util.Collection<? extends IntStream> c,
IntBiFunction<com.landawn.abacus.util.Nth> nextSelector) |
static IntStream |
merge(int[] a,
int[] b,
int[] c,
IntBiFunction<com.landawn.abacus.util.Nth> nextSelector) |
static IntStream |
merge(int[] a,
int[] b,
IntBiFunction<com.landawn.abacus.util.Nth> nextSelector) |
static IntStream |
merge(IntIterator a,
IntIterator b,
IntBiFunction<com.landawn.abacus.util.Nth> nextSelector) |
static IntStream |
merge(IntIterator a,
IntIterator b,
IntIterator c,
IntBiFunction<com.landawn.abacus.util.Nth> nextSelector) |
abstract IntStream |
merge(IntStream b,
IntBiFunction<com.landawn.abacus.util.Nth> nextSelector) |
static IntStream |
merge(IntStream a,
IntStream b,
IntBiFunction<com.landawn.abacus.util.Nth> nextSelector) |
static IntStream |
merge(IntStream a,
IntStream b,
IntStream c,
IntBiFunction<com.landawn.abacus.util.Nth> nextSelector) |
abstract OptionalInt |
min()
Returns an
OptionalInt describing the minimum element of this
stream, or an empty optional if this stream is empty. |
static IntStream |
of(int... a) |
static IntStream |
of(int[][] a) |
static IntStream |
of(int[][][] a) |
static IntStream |
of(int[] a,
int startIndex,
int endIndex) |
static IntStream |
of(IntIterator iterator) |
static IntStream |
of(java.util.stream.IntStream stream) |
static IntStream |
of(Supplier<IntList> supplier)
Lazy evaluation.
|
static IntStream |
ofCodePoints(java.lang.CharSequence str) |
S |
parallel()
Returns an equivalent stream that is parallel.
|
S |
parallel(BaseStream.Splitor splitor)
Returns an equivalent stream that is parallel.
|
S |
parallel(int maxThreadNum)
Returns an equivalent stream that is parallel.
|
static IntStream |
parallelMerge(java.util.Collection<? extends IntStream> c,
IntBiFunction<com.landawn.abacus.util.Nth> nextSelector) |
static IntStream |
parallelMerge(java.util.Collection<? extends IntStream> c,
IntBiFunction<com.landawn.abacus.util.Nth> nextSelector,
int maxThreadNum) |
void |
println() |
static IntStream |
random() |
static IntStream |
random(int startInclusive,
int endExclusive) |
static IntStream |
range(int startInclusive,
int endExclusive) |
static IntStream |
range(int startInclusive,
int endExclusive,
int by) |
static IntStream |
rangeClosed(int startInclusive,
int endInclusive) |
static IntStream |
rangeClosed(int startInclusive,
int endInclusive,
int by) |
abstract OptionalInt |
reduce(IntBinaryOperator op)
Performs a reduction on the
elements of this stream, using an
associative accumulation
function, and returns an
OptionalInt describing the reduced value,
if any. |
abstract int |
reduce(int identity,
IntBinaryOperator op)
Performs a reduction on the
elements of this stream, using the provided identity value and an
associative
accumulation function, and returns the reduced value.
|
static IntStream |
repeat(int element,
long n) |
abstract IntStream |
scan(IntBiFunction<java.lang.Integer> accumulator)
Returns a
Stream produced by iterative application of a accumulation function
to an initial element seed and next element of the current stream. |
abstract IntStream |
scan(int seed,
IntBiFunction<java.lang.Integer> accumulator)
Returns a
Stream produced by iterative application of a accumulation function
to an initial element seed and next element of the current stream. |
S |
sequential()
Returns an equivalent stream that is sequential.
|
Stream<S> |
sliding(int windowSize) |
Stream<PL> |
slidingToList(int windowSize) |
BaseStream.Splitor |
splitor()
Return the underlying
splitor if the stream is parallel, otherwise the default value splitor.ITERATOR is returned. |
S |
splitor(BaseStream.Splitor splitor)
Returns a parallel stream with the specified
splitor . |
abstract long |
sum()
Returns the sum of elements in this stream.
|
abstract IntSummaryStatistics |
summarize() |
abstract Pair<IntSummaryStatistics,Optional<java.util.Map<com.landawn.abacus.util.Percentage,java.lang.Integer>>> |
summarize2() |
abstract IntStream |
tail()
Head and tail should be used by pair.
|
abstract OptionalInt |
tail2()
Head2 and tail2 should be used by pair.
|
abstract IntList |
toIntList() |
abstract <K,A,D> java.util.Map<K,D> |
toMap(IntFunction<? extends K> classifier,
Collector<java.lang.Integer,A,D> downstream) |
abstract <K,A,D,M extends java.util.Map<K,D>> |
toMap(IntFunction<? extends K> classifier,
Collector<java.lang.Integer,A,D> downstream,
Supplier<M> mapFactory) |
abstract <K,U> java.util.Map<K,U> |
toMap(IntFunction<? extends K> keyExtractor,
IntFunction<? extends U> valueMapper) |
abstract <K,U> java.util.Map<K,U> |
toMap(IntFunction<? extends K> keyExtractor,
IntFunction<? extends U> valueMapper,
BinaryOperator<U> mergeFunction) |
abstract <K,U,M extends java.util.Map<K,U>> |
toMap(IntFunction<? extends K> keyExtractor,
IntFunction<? extends U> valueMapper,
BinaryOperator<U> mergeFunction,
Supplier<M> mapFactory) |
abstract <K,U,M extends java.util.Map<K,U>> |
toMap(IntFunction<? extends K> keyExtractor,
IntFunction<? extends U> valueMapper,
Supplier<M> mapFactory) |
abstract IntMatrix |
toMatrix() |
abstract IntStream |
top(int n)
This method only run sequentially, even in parallel stream. |
abstract IntStream |
top(int n,
java.util.Comparator<? super java.lang.Integer> comparator)
This method only run sequentially, even in parallel stream. |
Try<S> |
tried() |
static IntStream |
zip(java.util.Collection<? extends IntStream> c,
int[] valuesForNone,
IntNFunction<java.lang.Integer> zipFunction)
Zip together the iterators until all of them runs out of values.
|
static IntStream |
zip(java.util.Collection<? extends IntStream> c,
IntNFunction<java.lang.Integer> zipFunction)
Zip together the iterators until one of them runs out of values.
|
static IntStream |
zip(int[] a,
int[] b,
int[] c,
int valueForNoneA,
int valueForNoneB,
int valueForNoneC,
IntTriFunction<java.lang.Integer> zipFunction)
Zip together the "a", "b" and "c" iterators until all of them runs out of values.
|
static IntStream |
zip(int[] a,
int[] b,
int[] c,
IntTriFunction<java.lang.Integer> zipFunction)
Zip together the "a", "b" and "c" arrays until one of them runs out of values.
|
static IntStream |
zip(int[] a,
int[] b,
IntBiFunction<java.lang.Integer> zipFunction)
Zip together the "a" and "b" arrays until one of them runs out of values.
|
static IntStream |
zip(int[] a,
int[] b,
int valueForNoneA,
int valueForNoneB,
IntBiFunction<java.lang.Integer> zipFunction)
Zip together the "a" and "b" iterators until all of them runs out of values.
|
static IntStream |
zip(IntIterator a,
IntIterator b,
IntBiFunction<java.lang.Integer> zipFunction)
Zip together the "a" and "b" iterators until one of them runs out of values.
|
static IntStream |
zip(IntIterator a,
IntIterator b,
int valueForNoneA,
int valueForNoneB,
IntBiFunction<java.lang.Integer> zipFunction)
Zip together the "a" and "b" iterators until all of them runs out of values.
|
static IntStream |
zip(IntIterator a,
IntIterator b,
IntIterator c,
int valueForNoneA,
int valueForNoneB,
int valueForNoneC,
IntTriFunction<java.lang.Integer> zipFunction)
Zip together the "a", "b" and "c" iterators until all of them runs out of values.
|
static IntStream |
zip(IntIterator a,
IntIterator b,
IntIterator c,
IntTriFunction<java.lang.Integer> zipFunction)
Zip together the "a", "b" and "c" iterators until one of them runs out of values.
|
static IntStream |
zip(IntStream a,
IntStream b,
IntBiFunction<java.lang.Integer> zipFunction)
Zip together the "a" and "b" streams until one of them runs out of values.
|
static IntStream |
zip(IntStream a,
IntStream b,
int valueForNoneA,
int valueForNoneB,
IntBiFunction<java.lang.Integer> zipFunction)
Zip together the "a" and "b" iterators until all of them runs out of values.
|
static IntStream |
zip(IntStream a,
IntStream b,
IntStream c,
int valueForNoneA,
int valueForNoneB,
int valueForNoneC,
IntTriFunction<java.lang.Integer> zipFunction)
Zip together the "a", "b" and "c" iterators until all of them runs out of values.
|
static IntStream |
zip(IntStream a,
IntStream b,
IntStream c,
IntTriFunction<java.lang.Integer> zipFunction)
Zip together the "a", "b" and "c" streams until one of them runs out of values.
|
abstract IntStream |
zipWith(IntStream b,
IntBiFunction<java.lang.Integer> zipFunction) |
abstract IntStream |
zipWith(IntStream b,
int valueForNoneA,
int valueForNoneB,
IntBiFunction<java.lang.Integer> zipFunction) |
abstract IntStream |
zipWith(IntStream b,
IntStream c,
int valueForNoneA,
int valueForNoneB,
int valueForNoneC,
IntTriFunction<java.lang.Integer> zipFunction) |
abstract IntStream |
zipWith(IntStream b,
IntStream c,
IntTriFunction<java.lang.Integer> zipFunction) |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
allMatch, anyMatch, append, cached, count, difference, distinct, dropWhile, filter, findFirst, findFirstOrLast, findLast, first, forEach, indexed, intersection, join, join, last, limit, noneMatch, onClose, parallel, peek, percentiles, prepend, remove, removeIf, removeIf, removeWhile, reversed, reverseSorted, rotated, shuffled, shuffled, skip, sliding, slidingToList, sorted, split, split, split, splitAt, splitBy, splitToList, splitToList, splitToList, step, symmetricDifference, takeWhile, toArray, toList, toList, toLongMultiset, toLongMultiset, toMultiset, toMultiset, toSet, toSet
public abstract IntStream map(IntUnaryOperator mapper)
This is an intermediate operation.
mapper
- a non-interfering,
stateless
function to apply to each elementpublic abstract CharStream mapToChar(IntToCharFunction mapper)
public abstract ByteStream mapToByte(IntToByteFunction mapper)
public abstract ShortStream mapToShort(IntToShortFunction mapper)
public abstract LongStream mapToLong(IntToLongFunction mapper)
LongStream
consisting of the results of applying the
given function to the elements of this stream.
This is an intermediate operation.
mapper
- a non-interfering,
stateless
function to apply to each elementpublic abstract FloatStream mapToFloat(IntToFloatFunction mapper)
FloatStream
consisting of the results of applying the
given function to the elements of this stream.
This is an intermediate operation.
mapper
- a non-interfering,
stateless
function to apply to each elementpublic abstract DoubleStream mapToDouble(IntToDoubleFunction mapper)
DoubleStream
consisting of the results of applying the
given function to the elements of this stream.
This is an intermediate operation.
mapper
- a non-interfering,
stateless
function to apply to each elementpublic abstract <U> Stream<U> mapToObj(IntFunction<? extends U> mapper)
Stream
consisting of the results of
applying the given function to the elements of this stream.
This is an intermediate operation.
U
- the element type of the new streammapper
- a non-interfering,
stateless
function to apply to each elementpublic abstract IntStream flatMap(IntFunction<? extends IntStream> mapper)
This is an intermediate operation.
mapper
- a non-interfering,
stateless
function to apply to each element which produces an
IntStream
of new valuesStream.flatMap(Function)
public abstract IntStream flatArray(IntFunction<int[]> mapper)
public abstract CharStream flatMapToChar(IntFunction<? extends CharStream> mapper)
public abstract ByteStream flatMapToByte(IntFunction<? extends ByteStream> mapper)
public abstract ShortStream flatMapToShort(IntFunction<? extends ShortStream> mapper)
public abstract LongStream flatMapToLong(IntFunction<? extends LongStream> mapper)
public abstract FloatStream flatMapToFloat(IntFunction<? extends FloatStream> mapper)
public abstract DoubleStream flatMapToDouble(IntFunction<? extends DoubleStream> mapper)
public abstract <T> Stream<T> flatMapToObj(IntFunction<? extends Stream<T>> mapper)
public abstract IntStream collapse(IntBiPredicate collapsible, IntBiFunction<java.lang.Integer> mergeFunction)
collapsible
- mergeFunction
- public abstract IntStream scan(IntBiFunction<java.lang.Integer> accumulator)
Stream
produced by iterative application of a accumulation function
to an initial element seed
and next element of the current stream.
Produces a Stream
consisting of seed
, acc(seed, value1)
,
acc(acc(seed, value1), value2)
, etc.
This is an intermediate operation.
Example:
accumulator: (a, b) -> a + b stream: [1, 2, 3, 4, 5] result: [1, 3, 6, 10, 15]
accumulator
- the accumulation functionpublic abstract IntStream scan(int seed, IntBiFunction<java.lang.Integer> accumulator)
Stream
produced by iterative application of a accumulation function
to an initial element seed
and next element of the current stream.
Produces a Stream
consisting of seed
, acc(seed, value1)
,
acc(acc(seed, value1), value2)
, etc.
This is an intermediate operation.
Example:
seed:10 accumulator: (a, b) -> a + b stream: [1, 2, 3, 4, 5] result: [11, 13, 16, 20, 25]
seed
- the initial value. it's only used once by accumulator
to calculate the fist element in the returned stream.
It will be ignored if this stream is empty and won't be the first element of the returned stream.accumulator
- the accumulation functionpublic abstract IntStream top(int n)
n
- public abstract IntStream top(int n, java.util.Comparator<? super java.lang.Integer> comparator)
n
- comparator
- public abstract IntList toIntList()
public abstract <K,U> java.util.Map<K,U> toMap(IntFunction<? extends K> keyExtractor, IntFunction<? extends U> valueMapper)
keyExtractor
- valueMapper
- Collectors.toMap(Function, Function)
public abstract <K,U,M extends java.util.Map<K,U>> M toMap(IntFunction<? extends K> keyExtractor, IntFunction<? extends U> valueMapper, Supplier<M> mapFactory)
keyExtractor
- valueMapper
- mapFactory
- Collectors.toMap(Function, Function, Supplier)
public abstract <K,U> java.util.Map<K,U> toMap(IntFunction<? extends K> keyExtractor, IntFunction<? extends U> valueMapper, BinaryOperator<U> mergeFunction)
keyExtractor
- valueMapper
- mergeFunction
- Collectors.toMap(Function, Function, BinaryOperator)
public abstract <K,U,M extends java.util.Map<K,U>> M toMap(IntFunction<? extends K> keyExtractor, IntFunction<? extends U> valueMapper, BinaryOperator<U> mergeFunction, Supplier<M> mapFactory)
keyExtractor
- valueMapper
- mergeFunction
- mapFactory
- Collectors.toMap(Function, Function, BinaryOperator, Supplier)
public abstract <K,A,D> java.util.Map<K,D> toMap(IntFunction<? extends K> classifier, Collector<java.lang.Integer,A,D> downstream)
classifier
- downstream
- Collectors.groupingBy(Function, Collector)
public abstract <K,A,D,M extends java.util.Map<K,D>> M toMap(IntFunction<? extends K> classifier, Collector<java.lang.Integer,A,D> downstream, Supplier<M> mapFactory)
classifier
- downstream
- mapFactory
- Collectors.groupingBy(Function, Collector, Supplier)
public abstract IntMatrix toMatrix()
public abstract int reduce(int identity, IntBinaryOperator op)
int result = identity;
for (int element : this stream)
result = accumulator.applyAsInt(result, element)
return result;
but is not constrained to execute sequentially.
The identity
value must be an identity for the accumulator
function. This means that for all x
,
accumulator.apply(identity, x)
is equal to x
.
The accumulator
function must be an
associative function.
This is a terminal operation.
identity
- the identity value for the accumulating functionop
- an associative,
non-interfering,
stateless
function for combining two valuessum()
,
min()
,
max()
,
average()
public abstract OptionalInt reduce(IntBinaryOperator op)
OptionalInt
describing the reduced value,
if any. This is equivalent to:
boolean foundAny = false;
int result = null;
for (int element : this stream) {
if (!foundAny) {
foundAny = true;
result = element;
}
else
result = accumulator.applyAsInt(result, element);
}
return foundAny ? OptionalInt.of(result) : OptionalInt.empty();
but is not constrained to execute sequentially.
The accumulator
function must be an
associative function.
This is a terminal operation.
op
- an associative,
non-interfering,
stateless
function for combining two valuesreduce(int, IntBinaryOperator)
public abstract <R> R collect(Supplier<R> supplier, ObjIntConsumer<R> accumulator, BiConsumer<R,R> combiner)
ArrayList
, and elements are incorporated by updating
the state of the result rather than by replacing the result. This
produces a result equivalent to:
R result = supplier.get();
for (int element : this stream)
accumulator.accept(result, element);
return result;
Like reduce(int, IntBinaryOperator)
, collect
operations
can be parallelized without requiring additional synchronization.
This is a terminal operation.
R
- type of the resultsupplier
- a function that creates a new result container. For a
parallel execution, this function may be called
multiple times and must return a fresh value each time.accumulator
- an associative,
non-interfering,
stateless
function for incorporating an additional element into a resultcombiner
- an associative,
non-interfering,
stateless
function for combining two values, which must be
compatible with the accumulator functionStream.collect(Supplier, BiConsumer, BiConsumer)
public abstract <R> R collect(Supplier<R> supplier, ObjIntConsumer<R> accumulator)
supplier
- accumulator
- public abstract OptionalInt head()
public abstract IntStream tail()
public abstract IntStream head2()
public abstract OptionalInt tail2()
public abstract Pair<OptionalInt,IntStream> headAndTail()
public abstract Pair<IntStream,OptionalInt> headAndTail2()
public abstract OptionalInt min()
OptionalInt
describing the minimum element of this
stream, or an empty optional if this stream is empty. This is a special
case of a reduction
and is equivalent to:
return reduce(Integer::min);
This is a terminal operation.
OptionalInt
containing the minimum element of this
stream, or an empty OptionalInt
if the stream is emptypublic abstract OptionalInt max()
OptionalInt
describing the maximum element of this
stream, or an empty optional if this stream is empty. This is a special
case of a reduction
and is equivalent to:
return reduce(Integer::max);
This is a terminal operation.
OptionalInt
containing the maximum element of this
stream, or an empty OptionalInt
if the stream is emptypublic abstract OptionalInt kthLargest(int k)
k
- public abstract long sum()
return reduce(0, Integer::sum);
This is a terminal operation.
public abstract OptionalDouble average()
OptionalDouble
describing the arithmetic mean of elements of
this stream, or an empty optional if this stream is empty. This is a
special case of a
reduction.
This is a terminal operation.
OptionalDouble
containing the average element of this
stream, or an empty optional if the stream is emptypublic abstract IntSummaryStatistics summarize()
public abstract Pair<IntSummaryStatistics,Optional<java.util.Map<com.landawn.abacus.util.Percentage,java.lang.Integer>>> summarize2()
public abstract IntStream merge(IntStream b, IntBiFunction<com.landawn.abacus.util.Nth> nextSelector)
b
- nextSelector
- first parameter is selected if Nth.FIRST
is returned, otherwise the second parameter is selected.public abstract IntStream zipWith(IntStream b, IntBiFunction<java.lang.Integer> zipFunction)
public abstract IntStream zipWith(IntStream b, IntStream c, IntTriFunction<java.lang.Integer> zipFunction)
public abstract IntStream zipWith(IntStream b, int valueForNoneA, int valueForNoneB, IntBiFunction<java.lang.Integer> zipFunction)
public abstract IntStream zipWith(IntStream b, IntStream c, int valueForNoneA, int valueForNoneB, int valueForNoneC, IntTriFunction<java.lang.Integer> zipFunction)
public abstract LongStream asLongStream()
LongStream
consisting of the elements of this stream,
converted to long
.
This is an intermediate operation.
LongStream
consisting of the elements of this stream,
converted to long
public abstract FloatStream asFloatStream()
FloatStream
consisting of the elements of this stream,
converted to double
.
This is an intermediate operation.
FloatStream
consisting of the elements of this stream,
converted to double
public abstract DoubleStream asDoubleStream()
DoubleStream
consisting of the elements of this stream,
converted to double
.
This is an intermediate operation.
DoubleStream
consisting of the elements of this stream,
converted to double
public abstract Stream<java.lang.Integer> boxed()
Stream
consisting of the elements of this stream,
each boxed to an Integer
.
This is an intermediate operation.
Stream
consistent of the elements of this stream,
each boxed to an Integer
public IntIterator iterator()
BaseStream
public static IntStream empty()
@SafeVarargs public static IntStream of(int... a)
public static IntStream of(int[] a, int startIndex, int endIndex)
public static IntStream of(int[][] a)
public static IntStream of(int[][][] a)
public static IntStream of(IntIterator iterator)
public static IntStream of(Supplier<IntList> supplier)
supplier
- public static IntStream of(java.util.stream.IntStream stream)
public static IntStream ofCodePoints(java.lang.CharSequence str)
@SafeVarargs public static IntStream from(char... a)
public static IntStream from(char[] a, int fromIndex, int toIndex)
@SafeVarargs public static IntStream from(byte... a)
public static IntStream from(byte[] a, int fromIndex, int toIndex)
@SafeVarargs public static IntStream from(short... a)
public static IntStream from(short[] a, int fromIndex, int toIndex)
public static IntStream range(int startInclusive, int endExclusive)
public static IntStream range(int startInclusive, int endExclusive, int by)
public static IntStream rangeClosed(int startInclusive, int endInclusive)
public static IntStream rangeClosed(int startInclusive, int endInclusive, int by)
public static IntStream repeat(int element, long n)
public static IntStream random()
public static IntStream random(int startInclusive, int endExclusive)
public static IntStream iterate(Supplier<java.lang.Boolean> hasNext, IntSupplier next)
public static IntStream iterate(int seed, Supplier<java.lang.Boolean> hasNext, IntUnaryOperator f)
public static IntStream iterate(int seed, IntPredicate hasNext, IntUnaryOperator f)
seed
- hasNext
- test if has next by hasNext.test(seed) for first time and hasNext.test(f.apply(previous)) for remaining.f
- public static IntStream iterate(int seed, IntUnaryOperator f)
public static IntStream generate(IntSupplier s)
@SafeVarargs public static IntStream concat(int[]... a)
@SafeVarargs public static IntStream concat(IntIterator... a)
public static IntStream zip(int[] a, int[] b, IntBiFunction<java.lang.Integer> zipFunction)
a
- b
- public static IntStream zip(int[] a, int[] b, int[] c, IntTriFunction<java.lang.Integer> zipFunction)
a
- b
- public static IntStream zip(IntIterator a, IntIterator b, IntBiFunction<java.lang.Integer> zipFunction)
a
- b
- public static IntStream zip(IntIterator a, IntIterator b, IntIterator c, IntTriFunction<java.lang.Integer> zipFunction)
a
- b
- public static IntStream zip(IntStream a, IntStream b, IntBiFunction<java.lang.Integer> zipFunction)
a
- b
- public static IntStream zip(IntStream a, IntStream b, IntStream c, IntTriFunction<java.lang.Integer> zipFunction)
a
- b
- public static IntStream zip(java.util.Collection<? extends IntStream> c, IntNFunction<java.lang.Integer> zipFunction)
c
- zipFunction
- public static IntStream zip(int[] a, int[] b, int valueForNoneA, int valueForNoneB, IntBiFunction<java.lang.Integer> zipFunction)
a
- b
- valueForNoneA
- value to fill if "a" runs out of values first.valueForNoneB
- value to fill if "b" runs out of values first.zipFunction
- public static IntStream zip(int[] a, int[] b, int[] c, int valueForNoneA, int valueForNoneB, int valueForNoneC, IntTriFunction<java.lang.Integer> zipFunction)
a
- b
- c
- valueForNoneA
- value to fill if "a" runs out of values.valueForNoneB
- value to fill if "b" runs out of values.valueForNoneC
- value to fill if "c" runs out of values.zipFunction
- public static IntStream zip(IntIterator a, IntIterator b, int valueForNoneA, int valueForNoneB, IntBiFunction<java.lang.Integer> zipFunction)
a
- b
- valueForNoneA
- value to fill if "a" runs out of values first.valueForNoneB
- value to fill if "b" runs out of values first.zipFunction
- public static IntStream zip(IntIterator a, IntIterator b, IntIterator c, int valueForNoneA, int valueForNoneB, int valueForNoneC, IntTriFunction<java.lang.Integer> zipFunction)
a
- b
- c
- valueForNoneA
- value to fill if "a" runs out of values.valueForNoneB
- value to fill if "b" runs out of values.valueForNoneC
- value to fill if "c" runs out of values.zipFunction
- public static IntStream zip(IntStream a, IntStream b, int valueForNoneA, int valueForNoneB, IntBiFunction<java.lang.Integer> zipFunction)
a
- b
- valueForNoneA
- value to fill if "a" runs out of values first.valueForNoneB
- value to fill if "b" runs out of values first.zipFunction
- public static IntStream zip(IntStream a, IntStream b, IntStream c, int valueForNoneA, int valueForNoneB, int valueForNoneC, IntTriFunction<java.lang.Integer> zipFunction)
a
- b
- c
- valueForNoneA
- value to fill if "a" runs out of values.valueForNoneB
- value to fill if "b" runs out of values.valueForNoneC
- value to fill if "c" runs out of values.zipFunction
- public static IntStream zip(java.util.Collection<? extends IntStream> c, int[] valuesForNone, IntNFunction<java.lang.Integer> zipFunction)
c
- valuesForNone
- value to fill for any iterator runs out of values.zipFunction
- public static IntStream merge(int[] a, int[] b, IntBiFunction<com.landawn.abacus.util.Nth> nextSelector)
a
- b
- nextSelector
- first parameter is selected if Nth.FIRST
is returned, otherwise the second parameter is selected.public static IntStream merge(int[] a, int[] b, int[] c, IntBiFunction<com.landawn.abacus.util.Nth> nextSelector)
a
- b
- c
- nextSelector
- first parameter is selected if Nth.FIRST
is returned, otherwise the second parameter is selected.public static IntStream merge(IntIterator a, IntIterator b, IntBiFunction<com.landawn.abacus.util.Nth> nextSelector)
a
- b
- nextSelector
- first parameter is selected if Nth.FIRST
is returned, otherwise the second parameter is selected.public static IntStream merge(IntIterator a, IntIterator b, IntIterator c, IntBiFunction<com.landawn.abacus.util.Nth> nextSelector)
a
- b
- c
- nextSelector
- first parameter is selected if Nth.FIRST
is returned, otherwise the second parameter is selected.public static IntStream merge(IntStream a, IntStream b, IntBiFunction<com.landawn.abacus.util.Nth> nextSelector)
a
- b
- nextSelector
- first parameter is selected if Nth.FIRST
is returned, otherwise the second parameter is selected.public static IntStream merge(IntStream a, IntStream b, IntStream c, IntBiFunction<com.landawn.abacus.util.Nth> nextSelector)
a
- b
- c
- nextSelector
- first parameter is selected if Nth.FIRST
is returned, otherwise the second parameter is selected.public static IntStream merge(java.util.Collection<? extends IntStream> c, IntBiFunction<com.landawn.abacus.util.Nth> nextSelector)
c
- nextSelector
- first parameter is selected if Nth.FIRST
is returned, otherwise the second parameter is selected.public static IntStream parallelMerge(java.util.Collection<? extends IntStream> c, IntBiFunction<com.landawn.abacus.util.Nth> nextSelector)
c
- nextSelector
- first parameter is selected if Nth.FIRST
is returned, otherwise the second parameter is selected.public static IntStream parallelMerge(java.util.Collection<? extends IntStream> c, IntBiFunction<com.landawn.abacus.util.Nth> nextSelector, int maxThreadNum)
c
- nextSelector
- first parameter is selected if Nth.FIRST
is returned, otherwise the second parameter is selected.maxThreadNum
- public S carry(C action)
BaseStream
peek
carry
in interface BaseStream<T,A,P,C,PL,OT,IT,S extends com.landawn.abacus.util.stream.StreamBase<T,A,P,C,PL,OT,IT,S>>
BaseStream.peek(Object)
public OT findAny(P predicate)
BaseStream
Optional
describing some element of the stream, or an
empty Optional
if the stream is empty.
This is a short-circuiting terminal operation.
The behavior of this operation is explicitly nondeterministic; it is
free to select any element in the stream. This is to allow for maximal
performance in parallel operations; the cost is that multiple invocations
on the same source may not return the same result. (If a stable result
is desired, use #findFirst()
instead.)
findAny
in interface BaseStream<T,A,P,C,PL,OT,IT,S extends com.landawn.abacus.util.stream.StreamBase<T,A,P,C,PL,OT,IT,S>>
Optional
describing some element of this stream, or an
empty Optional
if the stream is empty#findFirst()
public Stream<S> sliding(int windowSize)
sliding
in interface BaseStream<T,A,P,C,PL,OT,IT,S extends com.landawn.abacus.util.stream.StreamBase<T,A,P,C,PL,OT,IT,S>>
BaseStream.sliding(int, int)
public Stream<PL> slidingToList(int windowSize)
slidingToList
in interface BaseStream<T,A,P,C,PL,OT,IT,S extends com.landawn.abacus.util.stream.StreamBase<T,A,P,C,PL,OT,IT,S>>
BaseStream.sliding(int, int)
public void println()
println
in interface BaseStream<T,A,P,C,PL,OT,IT,S extends com.landawn.abacus.util.stream.StreamBase<T,A,P,C,PL,OT,IT,S>>
public boolean isParallel()
BaseStream
isParallel
in interface BaseStream<T,A,P,C,PL,OT,IT,S extends com.landawn.abacus.util.stream.StreamBase<T,A,P,C,PL,OT,IT,S>>
true
if this stream would execute in parallel if executedpublic S sequential()
BaseStream
sequential
in interface BaseStream<T,A,P,C,PL,OT,IT,S extends com.landawn.abacus.util.stream.StreamBase<T,A,P,C,PL,OT,IT,S>>
public S parallel()
BaseStream
parallel
in interface BaseStream<T,A,P,C,PL,OT,IT,S extends com.landawn.abacus.util.stream.StreamBase<T,A,P,C,PL,OT,IT,S>>
BaseStream.parallel(int, Splitor)
public S parallel(int maxThreadNum)
BaseStream
maxThreadNum
as the specified one.parallel
in interface BaseStream<T,A,P,C,PL,OT,IT,S extends com.landawn.abacus.util.stream.StreamBase<T,A,P,C,PL,OT,IT,S>>
BaseStream.parallel(int, Splitor)
public S parallel(BaseStream.Splitor splitor)
BaseStream
splitor
as the specified one.parallel
in interface BaseStream<T,A,P,C,PL,OT,IT,S extends com.landawn.abacus.util.stream.StreamBase<T,A,P,C,PL,OT,IT,S>>
BaseStream.parallel(int, Splitor)
public int maxThreadNum()
BaseStream
maxThreadNum
if the stream is parallel, otherwise 1
is returned.maxThreadNum
in interface BaseStream<T,A,P,C,PL,OT,IT,S extends com.landawn.abacus.util.stream.StreamBase<T,A,P,C,PL,OT,IT,S>>
public S maxThreadNum(int maxThreadNum)
BaseStream
maxThreadNum
. Or return
itself, either because the stream was already parallel with same maxThreadNum
, or because
it's a sequential stream.maxThreadNum
in interface BaseStream<T,A,P,C,PL,OT,IT,S extends com.landawn.abacus.util.stream.StreamBase<T,A,P,C,PL,OT,IT,S>>
public BaseStream.Splitor splitor()
BaseStream
splitor
if the stream is parallel, otherwise the default value splitor.ITERATOR
is returned.splitor
in interface BaseStream<T,A,P,C,PL,OT,IT,S extends com.landawn.abacus.util.stream.StreamBase<T,A,P,C,PL,OT,IT,S>>
public S splitor(BaseStream.Splitor splitor)
BaseStream
splitor
. Or return
itself, either because the stream was already parallel with same splitor
, or because
it's a sequential stream.splitor
in interface BaseStream<T,A,P,C,PL,OT,IT,S extends com.landawn.abacus.util.stream.StreamBase<T,A,P,C,PL,OT,IT,S>>
public Try<S> tried()
tried
in interface BaseStream<T,A,P,C,PL,OT,IT,S extends com.landawn.abacus.util.stream.StreamBase<T,A,P,C,PL,OT,IT,S>>
public void close()
BaseStream
close
in interface BaseStream<T,A,P,C,PL,OT,IT,S extends com.landawn.abacus.util.stream.StreamBase<T,A,P,C,PL,OT,IT,S>>
close
in interface java.lang.AutoCloseable
AutoCloseable.close()