groupSetsBy<K> method

Map<K, Set<T>> groupSetsBy<K>(
  1. K keyOf(
    1. T element
    )
)

Groups elements into sets by keyOf.

Implementation

Map<K, Set<T>> groupSetsBy<K>(K Function(T element) keyOf) {
  var result = <K, Set<T>>{};
  for (var element in this) {
    (result[keyOf(element)] ??= <T>{}).add(element);
  }
  return result;
}