Merge branch 'master' into bug4009

This commit is contained in:
Steffen Schaefer committed 2017-01-31 14:35:54 +01:00
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&lt;V&gt;} 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);