Praktikum 3: Ordnung

This commit is contained in:
Johannes Theiner 2018-04-25 13:26:11 +02:00
parent 39e025ef15
commit 3b50650702
1 changed files with 6 additions and 4 deletions

View File

@ -73,7 +73,8 @@ public class Vorlesungsverzeichnis implements Comparator<Vorlesung>{
*/ */
Map<String, Set<String>> map = vorlesungen.stream().collect(Collectors.groupingBy(Vorlesung::getDozent, Collectors.mapping(Vorlesung::getTitle, Collectors.toSet()))); Map<String, Set<String>> map = vorlesungen.stream().collect(
Collectors.groupingBy(Vorlesung::getDozent, Collectors.mapping(Vorlesung::getTitle, Collectors.toSet())));
Set<String> set = new HashSet<>(); Set<String> set = new HashSet<>();
map.forEach((s, strings) -> { map.forEach((s, strings) -> {
if(strings.size() >= 2) set.add(s); if(strings.size() >= 2) set.add(s);
@ -104,7 +105,8 @@ public class Vorlesungsverzeichnis implements Comparator<Vorlesung>{
} }
return map; return map;
*/ */
Map<String, List<String>> map = vorlesungen.stream().collect(Collectors.groupingBy(Vorlesung::getStudiengruppe, Collectors.mapping(Vorlesung::getTitle, Collectors.toList()))); Map<String, List<String>> map = vorlesungen.stream().collect(
Collectors.groupingBy(Vorlesung::getStudiengruppe, Collectors.mapping(Vorlesung::getTitle, Collectors.toList())));
map.forEach((s, strings) -> Collections.sort(strings)); map.forEach((s, strings) -> Collections.sort(strings));
return map; return map;
} }
@ -137,8 +139,8 @@ public class Vorlesungsverzeichnis implements Comparator<Vorlesung>{
} }
return map; return map;
*/ */
Map<String, List<String>> map = vorlesungen.stream().collect(Collectors.groupingBy(Vorlesung::getTitle, Collectors.mapping(Vorlesung::getDozent, Collectors.toList()))); Map<String, List<String>> map = vorlesungen.stream().collect(
Collectors.groupingBy(Vorlesung::getTitle, Collectors.mapping(Vorlesung::getDozent, Collectors.toList())));
Iterator<Map.Entry<String, List<String>>> iterator = map.entrySet().iterator(); Iterator<Map.Entry<String, List<String>>> iterator = map.entrySet().iterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {
Map.Entry<String, List<String>> entry = iterator.next(); Map.Entry<String, List<String>> entry = iterator.next();