range static method

IntStream range(
  1. int startInclusive,
  2. int endExclusive
)

Creates an IntStream from a range of integers.

The range includes startInclusive and excludes endExclusive.

Example

final numbers = GenericStream.range(1, 10); // 1, 2, 3, 4, 5, 6, 7, 8, 9

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 range(int startInclusive, int endExclusive) {
  return IntStream.range(startInclusive, endExclusive);
}