mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-21 05:51:25 +07:00
IDEA-195573 groupingBy test
This commit is contained in:
@@ -48,4 +48,12 @@ public class Main {
|
||||
return result;
|
||||
}));
|
||||
}
|
||||
|
||||
void sample4(List<String> people) {
|
||||
Map<Integer, List<String>> result = new HashMap<>();
|
||||
for (String person : people) {
|
||||
result.computeIfAbsent(person.length(), k -> new ArrayList<>()).add(person);
|
||||
}
|
||||
Map<Integer, List<String>> map = Collections.unmodifiableMap(result);
|
||||
}
|
||||
}
|
||||
@@ -30,4 +30,10 @@ public class Main {
|
||||
Collectors.collectingAndThen(Collectors.<String, List<String>>toCollection(LinkedList::new),
|
||||
list -> Stream.concat(list.stream(), list.stream()).collect(Collectors.toList())));
|
||||
}
|
||||
|
||||
void sample4(List<String> people) {
|
||||
Map<Integer, List<String>> map = people.stream().collect(
|
||||
Collectors.collectingAndThen(Collectors.groupingBy(String::length),
|
||||
m -> Collections.unmodifiableMap(m)));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user