Java Map Remove remove(Map map, Collection keys)

Here you can find the source of remove(Map map, Collection keys)

Description

 

License

Apache License

Parameter

Parameter Description
map a parameter
keys a parameter

Declaration

public static <K, V> void remove(Map<K, V> map, Collection<K> keys) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.Collection;
import java.util.Map;

public class Main {
    /**//from ww w  . j a  v a  2s  .  c  o m
     * <pre>
     * </pre>
     * 
     * @param map
     * @param keys
     */
    public static <K, V> void remove(Map<K, V> map, Collection<K> keys) {
        if (map == null || map.isEmpty()) {
            return;
        }
        if (keys == null || keys.isEmpty()) {
            return;
        }
        for (K key : keys) {
            if (key == null) {
                continue;
            }
            map.remove(key);
        }
    }

    /**
     * <pre>
     * </pre>
     * 
     * @param map
     * @param keys
     */
    public static <K, V> void remove(Map<K, V> map, K[] keys) {
        if (map == null || map.isEmpty()) {
            return;
        }
        if (keys == null || keys.length == 0) {
            return;
        }
        for (K key : keys) {
            if (key == null) {
                continue;
            }
            map.remove(key);
        }
    }
}

Related

  1. remove(Map map, String key)
  2. remove(Map> map, K key, V value)
  3. remove(Map map, K key)
  4. removeAll(final Map target, final Iterable keys, Collection values)
  5. removeAll(Map map, Set keys)
  6. removeAllFromCollection(Map> map, Object key, Collection values)