mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-24 21:13:50 +00:00
Merge branch 'master' into bug4009
This commit is contained in:
commit
4bdd6420ec
64 files changed
+362
-103
No files matched your search
@@ -397,9 +397,27 @@ public class Util {
|
||||
* made. This is the caller's obligation.
|
||||
*/
|
||||
public static <K, V> void addToValueSet(Map<K, Set<V>> map, K key, V value) {
|
||||
addToValueSet(map, key, value, new ValueSetConstructor<V>() {
|
||||
@Override
|
||||
public Set<V> createSet() {
|
||||
return new HashSet<V>();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static interface ValueSetConstructor<T> {
|
||||
Set<T> createSet();
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that a {@link Set Set<V>} is contained in {@code map} for {@code key} and
|
||||
* then adds {@code value} to that set. No synchronization / concurrency control effort is
|
||||
* made. This is the caller's obligation.
|
||||
*/
|
||||
public static <K, V> void addToValueSet(Map<K, Set<V>> map, K key, V value, ValueSetConstructor<V> setConstructor) {
|
||||
Set<V> set = map.get(key);
|
||||
if (set == null) {
|
||||
set = new HashSet<V>();
|
||||
set = setConstructor.createSet();
|
||||
map.put(key, set);
|
||||
}
|
||||
set.add(value);
|
||||
|
||||
Reference in new issue
Block a user