nub method
Removes duplicates.
1, 1, 2, 2, 3, 3.nub() returns 1, 2, 3.
Optional parameter means .nub() will only apply to those elements:
1, 1, 1, 2, 2, 2, 3, 3, 3.nub(2, 3) returns 1, 1, 1, 2, 3.
Empty argument has no effect:
1, 1, 2, 2, 3, 3.nub([]) returns 1, 1, 2, 2, 3, 3.
Nested lists:
[1,2, 1,2].nub() returns [1,2].
Default h.symmetricDeepEquals checks DeepCollectionEquality().equals in both directions since it is asymmetric,
but equalityFunction allows a custom function to be used instead. For asymmetric
equality functions, elements are compared left to right.
Implementation
Queue<E> nub({
Iterable<E>? elementsToNub,
bool Function(E a, E b) equalityFunction = h.symmetricDeepEquals,
}) {
return h
.nubIterable(
original: this,
elementsToNub: elementsToNub,
equalityFunction: equalityFunction,
)
.toQueue();
}