Here you can find the source of removeValueFromAll(final Map map, final Object value)
Parameter | Description |
---|---|
map | the map. |
value | the value. |
static void removeValueFromAll(final Map map, final Object value)
//package com.java2s; import java.util.List; import java.util.Map; public class Main { /**/*from w w w .j av a 2s . com*/ * remove a value from all keys where it occurs. * * @param map * the map. * @param value * the value. */ static void removeValueFromAll(final Map map, final Object value) { final Object[] keys = map.keySet().toArray(); for (int i = 0; i < keys.length; i++) { List list = (List) map.get(keys[i]); list.remove(value); if (list.isEmpty()) { map.remove(keys[i]); } } } }