DistinctUniqueStreamTransformer<S> class Null safety

Create a Stream which implements a HashSet under the hood, using the provided equals as equality.

The Stream will only emit an event, if that event is not yet found within the underlying HashSet.

Example

Stream.fromIterable([1, 2, 1, 2, 1, 2, 3, 2, 1])
    .listen((event) => print(event));

will emit: 1, 2, 3

The provided equals must define a stable equivalence relation, and hashCode must be consistent with equals.

If equals or hashCode are omitted, the set uses the elements' intrinsic Object.== and Object.hashCode. If you supply one of equals and hashCode, you should generally also to supply the other.

Inheritance

Constructors

DistinctUniqueStreamTransformer({bool equals(S e1, S e2)?, int hashCodeMethod(S e)?})
Constructs a StreamTransformer which emits events from the source Stream as if they were processed through a HashSet.

Properties

equals → (bool Function?(S e1, S e2)?)
Optional method which determines equality between two events
final
hashCode int
The hash code for this object.
read-onlyinherited
hashCodeMethod → (int Function?(S e)?)
Optional method which is used to create a hash from an event
final
runtimeType Type
A representation of the runtime type of the object.
read-onlyinherited

Methods

bind(Stream<S> stream) Stream<S>
Transforms the provided stream.
override
cast<RS, RT>() StreamTransformer<RS, RT>
Provides a StreamTransformer<RS, RT> view of this stream transformer.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

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