mode method

Set<E> mode({
  1. bool equalityFunction(
    1. E a,
    2. E b
    ) = h.symmetricDeepEquals,
})

Returns the element(s) with the most occurrences.

1, 1, 2, 2, 3.mode() returns 1, 2.

[].mode() returns [].

Default h.symmetricDeepEquals compares DeepCollectionEquality().equals in both directions to count occurrences since it is normally asymmetric. Custom equalityFunction can be used which compares earlier elements to later elements.

Implementation

Set<E> mode({
  bool Function(E a, E b) equalityFunction = h.symmetricDeepEquals,
}) {
  return h
      .modeIterable(
        original: this,
        equalityFunction: equalityFunction,
      )
      .toSet();
}