rangeClosed static method

IntStream rangeClosed(
  1. int startInclusive,
  2. int endInclusive
)

Creates an IntStream from a closed range of integers.

The range includes both startInclusive and endInclusive.

Example

final numbers = GenericStream.rangeClosed(1, 5); // 1, 2, 3, 4, 5

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

static IntStream rangeClosed(int startInclusive, int endInclusive) {
  return IntStream.rangeClosed(startInclusive, endInclusive);
}