Java Map Remove removeValueFromAll(final Map map, final Object value)

Here you can find the source of removeValueFromAll(final Map map, final Object value)

Description

remove a value from all keys where it occurs.

License

Open Source License

Parameter

Parameter Description
map the map.
value the value.

Declaration

static void removeValueFromAll(final Map map, final Object value) 

Method Source Code

//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]);
            }
        }
    }
}

Related

  1. removePrivateColumns( Map contentValues)
  2. removeRownum(List> rows)
  3. removeTrailingNumber(Map names)
  4. removeValue(final Map map, final Object key, final Object value)
  5. removeValue(Map subject, String property, Map value, boolean propertyIsArray)
  6. removeValueList(final Map> map, final K key, final V value)
  7. removeValuesFromMap(Map map, Collection removed)
  8. removeVersionSelector( Map selector)
  9. removeWireAttributes( Map map)