StandardGenericStream<T> class

Implementation of GenericStream that wraps an Iterable and provides some basic stream operations.

This class is not intended to be used directly. Instead, use the factory methods in GenericStream to create a stream.

The GenericStream class provides a unified API for working with streams of elements. It is the base class for other stream classes, such as IntStream and DoubleStream.

A stream is a sequence of elements supporting aggregate operations. Streams are created from various data sources, such as collections, arrays, or I/O channels. They are lazily evaluated, meaning that the computation is only performed when the elements of the stream are consumed.

Streams are consumable, meaning that their elements can only be visited once. After all elements have been consumed, the stream is considered exhausted and no longer usable.

Streams are auto-closeable, meaning that they can be used as resources in a try-finally statement. When a stream is closed, all of its resources are released.

Implemented types
Annotations

Constructors

StandardGenericStream(Iterable<T> _source, [bool _parallel = false, List<void Function()> _closeHandlers = const []])
StandardGenericStream.empty()
factory
StandardGenericStream.generate(T supplier())
factory
StandardGenericStream.iterate(T seed, T f(T))
factory
StandardGenericStream.of(Iterable<T> values)
factory
StandardGenericStream.ofSingle(T value)
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(T)) bool
Returns whether all elements of this stream match the provided predicate.
override
anyMatch(bool predicate(T)) bool
Returns whether any elements of this stream match the provided predicate.
override
close() → void
Closes this stream, causing all close handlers for this stream pipeline to be called.
override
collect() List<T>
Returns a list containing the elements of this stream.
override
collectFrom<A, R>(Collector<T, A, R> collector) → R
Performs a mutable reduction operation on the elements of this stream using a Collector.
override
count() int
Returns the count of elements in this stream.
override
distinct() GenericStream<T>
Returns a stream consisting of the distinct elements (according to Object.==) of this stream.
override
dropWhile(bool predicate(T)) GenericStream<T>
Returns a stream consisting of the remaining elements of this stream after dropping the longest prefix of elements that match the given predicate.
override
filter(bool predicate(T)) GenericStream<T>
Returns a stream consisting of the elements of this stream that match the given predicate.
override
findAny() Optional<T>
Returns an Optional describing some element of the stream, or an empty Optional if the stream is empty.
override
findFirst() Optional<T>
Returns an Optional describing the first element of this stream, or an empty Optional if the stream is empty.
override
flatMap<R>(GenericStream<R> mapper(T)) GenericStream<R>
Returns a stream consisting of the results of replacing each element of this stream with the contents of a mapped stream produced by applying the provided mapping function to each element.
override
forEach(void action(T)) → void
Performs an action for each element of this stream.
override
forEachOrdered(void action(T)) → void
Performs an action for each element of this stream, in the encounter order of the stream if the stream has a defined encounter order.
override
isParallel() bool
Returns whether this stream, if a terminal operation were to be executed, would execute in parallel.
override
iterable() Iterable<T>
Returns an iterable for the elements of this stream.
override
iterator() Iterator<T>
Returns an iterator for the elements of this stream.
override
limit(int maxSize) GenericStream<T>
Returns a stream consisting of the elements of this stream, truncated to be no longer than maxSize in length.
override
map<R>(R mapper(T)) GenericStream<R>
Returns a stream consisting of the results of applying the given function to the elements of this stream.
override
mapToDouble(double mapper(T)) DoubleStream
Returns a DoubleStream consisting of the results of applying the given function to the elements of this stream.
override
mapToInt(int mapper(T)) IntStream
Returns an IntStream consisting of the results of applying the given function to the elements of this stream.
override
max([int comparator(T, T)?]) Optional<T>
Returns the maximum element of this stream according to the provided Comparator.
override
min([int comparator(T, T)?]) Optional<T>
Returns the minimum element of this stream according to the provided Comparator.
override
noneMatch(bool predicate(T)) bool
Returns whether no elements of this stream match the provided predicate.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onClose(void closeHandler()) GenericStream<T>
Returns an equivalent stream with an additional close handler.
override
parallel() GenericStream<T>
Returns an equivalent stream that is parallel.
override
peek(void action(T)) GenericStream<T>
Returns a stream consisting of the elements of this stream, additionally performing the provided action on each element as elements are consumed from the resulting stream.
override
reduce(T identity, T accumulator(T, T)) → T
Performs a reduction on the elements of this stream, using the provided identity value and an associative accumulation function, and returns the reduced value.
override
reduceOptional(T accumulator(T, T)) Optional<T>
Performs a reduction on the elements of this stream, using an associative accumulation function, and returns an Optional describing the reduced value, if any.
override
sequential() GenericStream<T>
Returns an equivalent stream that is sequential.
override
skip(int n) GenericStream<T>
Returns a stream consisting of the remaining elements of this stream after discarding the first n elements of the stream.
override
sorted([int comparator(T, T)?]) GenericStream<T>
Returns a stream consisting of the elements of this stream, sorted according to natural order.
override
takeWhile(bool predicate(T)) GenericStream<T>
Returns a stream consisting of the longest prefix of elements taken from this stream that match the given predicate.
override
toList() List<T>
Returns a List containing the elements of this stream.
override
toSet() Set<T>
Returns a Set containing the elements of this stream.
override
toString() String
A string representation of this object.
inherited
unordered() GenericStream<T>
Returns an equivalent stream that is unordered.
override
where(Predicate<T> predicate) GenericStream<T>
Returns the first element of this stream that matches the given predicate.
override

Operators

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