A notion of equality for a collection: an equals that is reflexive, symmetric and transitive,
and a hash that returns the same finite number for equal values.
Collections read both functions once, when they are created, and call them with this set to
the equivalence. equals must return a boolean.
Example
constcaseInsensitive: Equivalence<string> = { equals: (a, b) =>a.toLowerCase() === b.toLowerCase(), hash: (s) =>hashCode(s.toLowerCase()), }
A notion of equality for a collection: an
equalsthat is reflexive, symmetric and transitive, and ahashthat returns the same finite number for equal values.Collections read both functions once, when they are created, and call them with
thisset to the equivalence.equalsmust return a boolean.Example