of<T extends Comparable<T> > static method
Returns an EqualityComparer where the sorter
and optionally comparer
methods
are set to call the Comparable.compareTo method of the provided type.
The hasher
method is set to the default hasher behavior of calling
Object.hashCode.
If useEquals
is true, comparer
will use the default comparer behavior
(a, b) => a == b
. Otherwise, it will use Comparable.compareTo to
determine equality, e.g. (a, b) => a.compareTo(b) == 0
.
Implementation
static EqualityComparer<T> of<T extends Comparable<T>>(
{bool useEquals = false}) {
return EqualityComparer<T>(
comparer: useEquals
? _getDefaultComparer<T>()
: (T left, T right) => left.compareTo(right) == 0,
sorter: (T left, T right) => left.compareTo(right),
hasher: _getDefaultHasher<T>(),
);
}