Closed
Description
In C#, distinct
and distinctUntilChanged
take an IEqualityComparer
(which provides Equals
and GetHashCode
).
That's not the same as java.util.Comparator
(which provides compare
).
Or mathematically speaking: There are two kinds of comparators:
- Those which define a total ordering:
java.util.Comparator
and C#'sIComparer
- Those which define an equivalence relation: C#'s
IEqualityComparer
, RxJava'sFunc2<T, T, Boolean>
, and unfortunately no standard Java interface
The problem is that for distinct
and distinctUntilChanged
, we're not interested in an order on the elements, but only in equality.
So it would be better to use Func2<? super T, ? super T, Boolean> equality
(just like sequenceEqual
) instead of Comparator<U> equalityComparator
.
Metadata
Metadata
Assignees
Labels
No labels