IntStream.empty constructor

IntStream.empty()

Creates an empty IntStream.

Example

final stream = IntStream.empty();
print(stream.count()); // 0

A sequence of primitive int-valued elements supporting sequential and parallel aggregate operations.

This is the int primitive specialization of BaseStream. It supports fluent-style functional operations such as map, filter, reduce, and terminal operations for processing or collecting data.

Example Usage

// Create an IntStream from a range
final sum = IntStream.range(1, 10)
    .filter((n) => n % 2 == 0)
    .sum();
print(sum); // 20

// Statistical operations
final stats = IntStream.of([1, 2, 3, 4, 5])
    .summaryStatistics();
print('Average: ${stats.average}');
print('Max: ${stats.max}');

// Complex transformations
final result = IntStream.range(1, 100)
    .filter((n) => n % 3 == 0)
    .map((n) => n * n)
    .limit(5)
    .toList();

Implementation

factory IntStream.empty() = IntStreamImplementation.empty;