Esempio n. 1
1
 @SuppressWarnings("unchecked")
 @Override
 default <C> Map<C, Seq<T>> groupBy(Function<? super T, ? extends C> classifier) {
   Objects.requireNonNull(classifier, "classifier is null");
   if (isEmpty()) {
     return HashMap.empty();
   } else {
     return (Map<C, Seq<T>>) traverse().groupBy(classifier);
   }
 }
Esempio n. 2
1
 @Override
 public <C> Map<C, Array<T>> groupBy(Function<? super T, ? extends C> classifier) {
   return foldLeft(
       HashMap.empty(),
       (map, t) -> {
         final C key = classifier.apply(t);
         final Array<T> values = map.get(key).map(ts -> ts.append(t)).getOrElse(of(t));
         return map.put(key, values);
       });
 }