1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2025-12-07 21:01:16 +01:00

Add MultiMap.flatten()

This commit is contained in:
Paul Schaub 2023-06-05 19:44:47 +02:00
parent 41d734f2db
commit 324302c536
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311
2 changed files with 34 additions and 0 deletions

View file

@ -100,6 +100,19 @@ public class MultiMap<K, V> {
return map.entrySet();
}
/**
* Return all values of the {@link MultiMap} in a single {@link LinkedHashSet}.
*
* @return set of all values
*/
public Set<V> flatten() {
LinkedHashSet<V> flattened = new LinkedHashSet<>();
for (Set<V> items : map.values()) {
flattened.addAll(items);
}
return flattened;
}
@Override
public boolean equals(Object o) {
if (o == null) {