Skip to content
Buy me a coffee

LongStream

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

A stream of long integers (JS numbers, exact up to Number.MAX_SAFE_INTEGER). The LongStream value holds the factories.

  • LongStream

[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

LongStreamType.[dispose]


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

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

Iterator<number, any, any>

LongStreamType.[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

LongStreamType.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

LongStreamType.anyMatch


asDoubleStream(): DoubleStream

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

Returns the same values as a DoubleStream (no longer reported DISTINCT). Intermediate.

DoubleStream

LongStreamType.asDoubleStream


average(): OptionalDouble

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

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

OptionalDouble

LongStreamType.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>

LongStreamType.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

LongStreamType.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

LongStreamType.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

LongStreamType.count


distinct(): LongStream

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.

LongStream

LongStreamType.distinct


dropWhile(predicate): LongStream

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

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

(n) => boolean

LongStream

LongStreamType.dropWhile


filter(predicate): LongStream

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

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

(n) => boolean

LongStream

LongStreamType.filter


findAny(): OptionalLong

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

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

OptionalLong

LongStreamType.findAny


findFirst(): OptionalLong

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

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

OptionalLong

LongStreamType.findFirst


flatMap(mapper): LongStream

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) => LongStream | null | undefined

LongStream

LongStreamType.flatMap


forEach(action): void

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

Runs action for each number in encounter order. Terminal.

(n) => void

void

LongStreamType.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

LongStreamType.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

LongStreamType.isParallel


iterator(): PrimitiveIteratorOfLong

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

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

PrimitiveIteratorOfLong

LongStreamType.iterator


limit(maxSize): LongStream

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

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

number

LongStream

IllegalArgumentException if maxSize is negative or not an integer

LongStreamType.limit


map(mapper): LongStream

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

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

(n) => number

LongStream

LongStreamType.map


mapMulti(mapper): LongStream

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

LongStream

LongStreamType.mapMulti


mapToDouble(mapper): DoubleStream

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

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

(n) => number

DoubleStream

LongStreamType.mapToDouble


mapToInt(mapper): IntStream

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

Returns an IntStream of mapper applied to each element. Intermediate.

(n) => number

IntStream

LongStreamType.mapToInt


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>

LongStreamType.mapToObj


max(): OptionalLong

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

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

OptionalLong

LongStreamType.max


min(): OptionalLong

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

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

OptionalLong

LongStreamType.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

LongStreamType.noneMatch


onClose(closeHandler): LongStream

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

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

() => void

LongStream

IllegalStateException if the stream was already operated upon or closed

NullPointerException if closeHandler is null

LongStreamType.onClose


parallel(): LongStream

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.

LongStream

LongStreamType.parallel


peek(action): LongStream

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

LongStream

LongStreamType.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

LongStreamType.reduce

reduce(op): OptionalLong

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

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

(a, b) => number

OptionalLong

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

LongStreamType.reduce


sequential(): LongStream

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

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

LongStream

LongStreamType.sequential


skip(n): LongStream

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

LongStream

IllegalArgumentException if n is negative or not an integer

LongStreamType.skip


sorted(): LongStream

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.

LongStream

LongStreamType.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

LongStreamType.spliterator


sum(): number

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

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

number

LongStreamType.sum


summaryStatistics(): LongSummaryStatistics

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

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

LongSummaryStatistics

LongStreamType.summaryStatistics


takeWhile(predicate): LongStream

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

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

(n) => boolean

LongStream

LongStreamType.takeWhile


toArray(): number[]

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

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

number[]

LongStreamType.toArray


unordered(): LongStream

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.

LongStream

IllegalStateException if the stream was already operated upon or closed

LongStreamType.unordered