DoubleStream class abstract

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

This is the double primitive specialization of BaseStream. It enables functional-style operations including transformation, filtering, reduction, and terminal collection.

Example Usage

// Create a DoubleStream from values
final average = DoubleStream.of([1.5, 2.5, 3.5, 4.5])
    .filter((d) => d > 2.0)
    .average();
print(average); // 3.5

// Statistical operations
final stats = DoubleStream.of([1.1, 2.2, 3.3, 4.4, 5.5])
    .summaryStatistics();
print('Sum: ${stats.sum}');
print('Average: ${stats.average}');

// Complex transformations
final result = DoubleStream.of([1.0, 2.0, 3.0, 4.0, 5.0])
    .map((d) => d * d)
    .filter((d) => d > 10.0)
    .toList();
Inheritance

Constructors

DoubleStream()
A sequence of primitive double-valued elements supporting sequential and parallel aggregate operations.
DoubleStream.empty()
Creates an empty DoubleStream.
factory
DoubleStream.of(Iterable<double> values)
Creates a DoubleStream from the given values.
factory

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

allMatch(bool predicate(double)) bool
Returns true if all elements match the predicate.
anyMatch(bool predicate(double)) bool
Returns true if any element matches the predicate.
average() Optional<double>
Computes and returns the average, or an empty Optional if the stream is empty.
close() → void
Closes this stream, causing all close handlers for this stream pipeline to be called.
inherited
collect() List<double>
Returns a list containing the elements of this stream.
inherited
count() int
Returns the count of elements.
distinct() DoubleStream
Returns a stream with duplicate elements removed.
dropWhile(bool predicate(double)) DoubleStream
Drops elements while the predicate is true, then returns the remainder.
filter(bool predicate(double)) DoubleStream
Filters elements based on the given predicate.
findAny() Optional<double>
Returns any element of the stream.
findFirst() Optional<double>
Returns the first element, if available.
flatMap(DoubleStream mapper(double)) DoubleStream
Flattens nested DoubleStreams generated by the mapping function.
forEach(void action(double)) → void
Applies the provided action to each element.
forEachOrdered(void action(double)) → void
Applies the action to elements in encounter order.
isParallel() bool
Returns whether this stream, if a terminal operation were to be executed, would execute in parallel.
inherited
iterable() Iterable<double>
Returns an iterable for the elements of this stream.
inherited
iterator() Iterator<double>
Returns an iterator for the elements of this stream.
inherited
limit(int maxSize) DoubleStream
Limits the stream to at most maxSize elements.
map(double mapper(double)) DoubleStream
Transforms each element using the provided mapping function.
mapToInt(int mapper(double)) IntStream
Maps each element to an int, returning an IntStream.
max() Optional<double>
Returns the maximum element or an empty Optional.
min() Optional<double>
Returns the minimum element or an empty Optional.
noneMatch(bool predicate(double)) bool
Returns true if none match the predicate.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onClose(void closeHandler()) DoubleStream
Returns an equivalent stream with an additional close handler.
inherited
parallel() DoubleStream
Returns an equivalent stream that is parallel.
inherited
peek(void action(double)) DoubleStream
Applies the action to each element and returns the same stream.
reduce(double identity, double op(double, double)) double
Reduces the stream using the identity and associative binary operator.
reduceOptional(double op(double, double)) Optional<double>
Returns an Optional reduction result.
sequential() DoubleStream
Returns an equivalent stream that is sequential.
inherited
skip(int n) DoubleStream
Skips the first n elements.
sorted() DoubleStream
Returns the stream sorted in natural (ascending) order.
sum() double
Sums the elements of the stream.
takeWhile(bool predicate(double)) DoubleStream
Takes elements while the predicate returns true.
toList() List<double>
Collects elements into a List of double.
toString() String
A string representation of this object.
inherited
unordered() DoubleStream
Returns an equivalent stream that is unordered.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited