Skip to content
Buy me a coffee

IntStream

Defined in: src/stream/Streams.ts:37

A stream of integers (JS numbers). The IntStream value holds the factories (IntStream.range, IntStream.of, …).

  • IntStream

[dispose](): void

Defined in: src/stream/Stream.ts:71

Calls close(), so using s = ... closes the stream at the end of the block. Present where the runtime has Symbol.dispose.

void

IntStreamType.[dispose]


[iterator](): Iterator<number, any, any>

Defined in: site/node_modules/typescript/lib/lib.es2015.iterable.d.ts:47

Iterator<number, any, any>

IntStreamType.[iterator]


allMatch(predicate): boolean

Defined in: src/stream/Stream.ts:382

Returns whether all numbers match predicate; true when empty. Terminal, short-circuiting.

(n) => boolean

boolean

IntStreamType.allMatch


anyMatch(predicate): boolean

Defined in: src/stream/Stream.ts:380

Returns whether any number matches predicate; false when empty. Terminal, short-circuiting.

(n) => boolean

boolean

IntStreamType.anyMatch


asDoubleStream(): DoubleStream

Defined in: src/stream/Stream.ts:408

Returns the same values as a DoubleStream. Intermediate.

DoubleStream

IntStreamType.asDoubleStream


asLongStream(): LongStream

Defined in: src/stream/Stream.ts:406

Returns the same values as a LongStream. Intermediate.

LongStream

IntStreamType.asLongStream


average(): OptionalDouble

Defined in: src/stream/Stream.ts:378

Returns the arithmetic mean, or an empty OptionalDouble for an empty stream. Terminal.

OptionalDouble

IntStreamType.average


boxed(): Stream<number>

Defined in: src/stream/Stream.ts:390

Returns a Stream of the same numbers, to use object-stream operations such as collect(collector). Intermediate.

Stream<number>

IntStreamType.boxed


close(): void

Defined in: src/stream/Stream.ts:69

Closes the stream and runs its close handlers once, in registration order. If handlers throw, the rest still run and the first error is rethrown with later ones attached via suppressed. A terminal operation does not close the stream; closing a closed stream does nothing.

void

IntStreamType.close


collect<R>(supplier, accumulator, combiner): R

Defined in: src/stream/Stream.ts:368

Performs a mutable reduction into the container supplier creates and returns it. Terminal. Only this three-argument form exists (call boxed() first to use a Collector); a one-argument call throws IllegalArgumentException.

R

() => R

(r, n) => void

(a, b) => void

R

IntStreamType.collect


count(): number

Defined in: src/stream/Stream.ts:376

Returns the number of elements; computed without traversal when the size is known exactly. Terminal.

number

IntStreamType.count


distinct(): IntStream

Defined in: src/stream/Stream.ts:325

Returns a stream without duplicate numbers, keeping the first occurrence. Intermediate, stateful. NaN equals NaN; in a DoubleStream -0 and 0 are different values.

IntStream

IntStreamType.distinct


dropWhile(predicate): IntStream

Defined in: src/stream/Stream.ts:346

Returns the numbers after the longest prefix matching predicate. Intermediate, stateful.

(n) => boolean

IntStream

IntStreamType.dropWhile


filter(predicate): IntStream

Defined in: src/stream/Stream.ts:309

Returns a stream of the numbers that match predicate. Intermediate, stateless.

(n) => boolean

IntStream

IntStreamType.filter


findAny(): OptionalInt

Defined in: src/stream/Stream.ts:388

Returns some number, or an empty optional; always the first here (sequential evaluation). Terminal, short-circuiting.

OptionalInt

IntStreamType.findAny


findFirst(): OptionalInt

Defined in: src/stream/Stream.ts:386

Returns the first number, or an empty optional. Terminal, short-circuiting.

OptionalInt

IntStreamType.findFirst


flatMap(mapper): IntStream

Defined in: src/stream/Stream.ts:318

Returns a stream that replaces each number with the numbers of the stream mapper returns. Intermediate. A null/undefined result counts as empty; each mapped stream is closed after use.

(n) => IntStream | null | undefined

IntStream

IntStreamType.flatMap


forEach(action): void

Defined in: src/stream/Stream.ts:348

Runs action for each number in encounter order. Terminal.

(n) => void

void

IntStreamType.forEach


forEachOrdered(action): void

Defined in: src/stream/Stream.ts:350

Runs action for each number in encounter order. Terminal; here the same as forEach.

(n) => void

void

IntStreamType.forEachOrdered


isParallel(): boolean

Defined in: src/stream/Stream.ts:44

Returns true if parallel() was requested. It only reports the flag; evaluation is always sequential.

boolean

IntStreamType.isParallel


iterator(): PrimitiveIteratorOfInt

Defined in: src/stream/Stream.ts:400

Returns a PrimitiveIteratorOfInt over the elements; a terminal operation that does not close the stream.

PrimitiveIteratorOfInt

IntStreamType.iterator


limit(maxSize): IntStream

Defined in: src/stream/Stream.ts:337

Returns a stream of at most the first maxSize numbers. Intermediate, stateful and short-circuiting.

number

IntStream

IllegalArgumentException if maxSize is negative or not an integer

IntStreamType.limit


map(mapper): IntStream

Defined in: src/stream/Stream.ts:311

Returns a stream of mapper applied to each number. Intermediate, stateless.

(n) => number

IntStream

IntStreamType.map


mapMulti(mapper): IntStream

Defined in: src/stream/Stream.ts:320

Returns a stream of the numbers mapper passes to consumer, zero or more per element. Intermediate, stateless.

(n, consumer) => void

IntStream

IntStreamType.mapMulti


mapToDouble(mapper): DoubleStream

Defined in: src/stream/Stream.ts:404

Returns a DoubleStream of mapper applied to each element. Intermediate.

(n) => number

DoubleStream

IntStreamType.mapToDouble


mapToLong(mapper): LongStream

Defined in: src/stream/Stream.ts:402

Returns a LongStream of mapper applied to each element. Intermediate.

(n) => number

LongStream

IntStreamType.mapToLong


mapToObj<U>(mapper): Stream<U>

Defined in: src/stream/Stream.ts:313

Returns a Stream of mapper applied to each number. Intermediate, stateless.

U

(n) => U

Stream<U>

IntStreamType.mapToObj


max(): OptionalInt

Defined in: src/stream/Stream.ts:374

Returns the largest number (as Math.max: NaN wins), or an empty optional. Terminal.

OptionalInt

IntStreamType.max


min(): OptionalInt

Defined in: src/stream/Stream.ts:372

Returns the smallest number (as Math.min: NaN wins), or an empty optional. Terminal.

OptionalInt

IntStreamType.min


noneMatch(predicate): boolean

Defined in: src/stream/Stream.ts:384

Returns whether no number matches predicate; true when empty. Terminal, short-circuiting.

(n) => boolean

boolean

IntStreamType.noneMatch


onClose(closeHandler): IntStream

Defined in: src/stream/Stream.ts:63

Registers a handler run by close() and returns this same stream; handlers run in registration order.

() => void

IntStream

IllegalStateException if the stream was already operated upon or closed

NullPointerException if closeHandler is null

IntStreamType.onClose


parallel(): IntStream

Defined in: src/stream/Stream.ts:51

Sets the parallel flag and returns this same stream. Evaluation stays sequential on the single JS thread; code written for parallel streams (associative reducers, combiners, findAny) gives the same results.

IntStream

IntStreamType.parallel


peek(action): IntStream

Defined in: src/stream/Stream.ts:332

Returns a stream that runs action on each number as it passes. Intermediate, stateless; meant for debugging.

(n) => void

IntStream

IntStreamType.peek


reduce(identity, op): number

Defined in: src/stream/Stream.ts:357

Folds the numbers, starting from identity, with an associative op. Terminal.

number

(a, b) => number

number

the result, or identity for an empty stream

IntStreamType.reduce

reduce(op): OptionalInt

Defined in: src/stream/Stream.ts:362

Folds the numbers with an associative op, without an initial value. Terminal.

(a, b) => number

OptionalInt

the result, or an empty number optional for an empty stream

IntStreamType.reduce


sequential(): IntStream

Defined in: src/stream/Stream.ts:46

Clears the parallel flag and returns this same stream. Allowed on a stream that was already used.

IntStream

IntStreamType.sequential


skip(n): IntStream

Defined in: src/stream/Stream.ts:342

Returns a stream without the first n numbers (this same stream when n is 0). Intermediate, stateful.

number

IntStream

IllegalArgumentException if n is negative or not an integer

IntStreamType.skip


sorted(): IntStream

Defined in: src/stream/Stream.ts:330

Returns a stream sorted in ascending numeric order (-0 before 0). Intermediate and a stateful barrier. There is no comparator form: use boxed().sorted(cmp); passing one from JS throws IllegalArgumentException.

IntStream

IntStreamType.sorted


spliterator(): Spliterator<number>

Defined in: src/stream/Stream.ts:42

Returns a Spliterator over the stream’s elements; a terminal operation that pulls elements lazily. It reports the pipeline’s characteristics (ORDERED, DISTINCT, SORTED, SIZED / SUBSIZED as the stages keep them); with no stages it is the source spliterator itself.

Spliterator<number>

IllegalStateException if the stream was already operated upon or closed

IntStreamType.spliterator


sum(): number

Defined in: src/stream/Stream.ts:370

Returns the sum of the numbers, 0 for an empty stream. Terminal.

number

IntStreamType.sum


summaryStatistics(): IntSummaryStatistics

Defined in: src/stream/Stream.ts:410

Returns the count, sum, min, max and average in one pass. Terminal.

IntSummaryStatistics

IntStreamType.summaryStatistics


takeWhile(predicate): IntStream

Defined in: src/stream/Stream.ts:344

Returns the longest prefix of numbers matching predicate. Intermediate, short-circuiting.

(n) => boolean

IntStream

IntStreamType.takeWhile


toArray(): number[]

Defined in: src/stream/Stream.ts:352

Returns a new JS array of the numbers in encounter order. Terminal.

number[]

IntStreamType.toArray


unordered(): IntStream

Defined in: src/stream/Stream.ts:57

Returns an equivalent stream without the encounter-order constraint (an intermediate operation), or this stream itself when it is already unordered. Evaluation is sequential, so elements still arrive in source order.

IntStream

IllegalStateException if the stream was already operated upon or closed

IntStreamType.unordered