group method

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

Items are grouped together if they are equal to the one next to it.

1, 2, 3, 3, 1.group() returns [1, 2, 3, 3, 1].

1.group() returns [1]. [].group() returns [].

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

Set<Set<E>> group(
    {bool Function(E a, E b) equalityFunction = h.symmetricDeepEquals}) {
  return h
      .groupIterable(
        original: this,
        equalityFunction: equalityFunction,
      )
      .toNestedSet();
}