diff options
author | Jon Bratseth <bratseth@verizonmedia.com> | 2019-07-02 17:47:31 -0700 |
---|---|---|
committer | Jon Bratseth <bratseth@verizonmedia.com> | 2019-07-02 17:47:31 -0700 |
commit | c7083bfed93168d74091dcf09844cdd27d95a279 (patch) | |
tree | 6a136504a194b2642c024f6e2eab66067f16d5f9 /vespajlib/src/main/java/com | |
parent | 0cd53c0204a8caf9fba1847d7f422cc51248f615 (diff) |
Add inequality constraints
Diffstat (limited to 'vespajlib/src/main/java/com')
-rw-r--r-- | vespajlib/src/main/java/com/yahoo/collections/ListMap.java | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/vespajlib/src/main/java/com/yahoo/collections/ListMap.java b/vespajlib/src/main/java/com/yahoo/collections/ListMap.java index 052ea55d6fe..479850beb1a 100644 --- a/vespajlib/src/main/java/com/yahoo/collections/ListMap.java +++ b/vespajlib/src/main/java/com/yahoo/collections/ListMap.java @@ -60,6 +60,18 @@ public class ListMap<K, V> { } } + /** Put this map in the state where it has just the given value of the given key */ + public void replace(K key, V value) { + List<V> list = map.get(key); + if (list == null) { + put(key); + } + else { + list.clear(); + list.add(value); + } + } + public void removeAll(K key) { map.remove(key); } |