DistinctUniqueStreamTransformer<T> class

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.

Constructors

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

Properties

hashCode → int
The hash code for this object.
read-only, inherited
runtimeType → Type
A representation of the runtime type of the object.
read-only, inherited

Methods

bind(Stream<T> stream) → Stream<T>
Transforms the provided stream. [...]
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
Returns a string representation of this object.
inherited

Operators

operator ==(dynamic other) → bool
The equality operator.
inherited