public synchronized void putAll(Map<? extends K, ? extends V> map) { for (Map.Entry<? extends K, ? extends V> entry : map.entrySet()) { put(entry.getKey(), entry.getValue()); } }
/** * If the specified key is not already associated with a value, associate it with the given value. This is equivalent to * * @param key * @param value * @return The value that was in the cache, null if none was there before */ public synchronized V putIfAbsent(K key, V value) { if (!containsKey(key)) { return put(key, value); } else { return get(key); } }
public synchronized void putAll(Map<? extends K, ? extends V> map) { for (Map.Entry<? extends K, ? extends V> entry : map.entrySet()) { put(entry.getKey(), entry.getValue()); } }
/** * If the specified key is not already associated with a value, associate it with the given value. This is equivalent to * * @param key * @param value * @return The value that was in the cache, null if none was there before */ public synchronized V putIfAbsent(K key, V value) { if (!containsKey(key)) { return put(key, value); } else { return get(key); } }