/** * Puts a key-value mapping into this map. * Neither the key nor the value may be null. * * @param key the key to add, must not be null * @param value the value to add, must not be null * @return the value previously mapped to this key, null if none * @throws NullPointerException if either the key or value is null */ public V put(K key, V value) { if (key == null) { throw new NullPointerException("null keys not allowed"); } if (value == null) { throw new NullPointerException("null values not allowed"); } purgeBeforeWrite(); return super.put(key, value); }
/** * Puts a key-value mapping into this map. * Neither the key nor the value may be null. * * @param key the key to add, must not be null * @param value the value to add, must not be null * @return the value previously mapped to this key, null if none * @throws NullPointerException if either the key or value is null */ public V put(K key, V value) { if (key == null) { throw new NullPointerException("null keys not allowed"); } if (value == null) { throw new NullPointerException("null values not allowed"); } purgeBeforeWrite(); return super.put(key, value); }
/** * Puts a key-value mapping into this map. * Neither the key nor the value may be null. * * @param key the key to add, must not be null * @param value the value to add, must not be null * @return the value previously mapped to this key, null if none * @throws NullPointerException if either the key or value is null */ public V put(K key, V value) { if (key == null) { throw new NullPointerException("null keys not allowed"); } if (value == null) { throw new NullPointerException("null values not allowed"); } purgeBeforeWrite(); return super.put(key, value); }
/** * Puts all the values from the specified map into this map. * <p/> * This implementation iterates around the specified map and * uses {@link #put(Object, Object)}. * * @param map the map to add * @throws NullPointerException if the map is null */ public void putAll(Map<? extends K, ? extends V> map) { int mapSize = map.size(); if (mapSize == 0) { return; } int newSize = (int) ((size + mapSize) / loadFactor + 1); ensureCapacity(calculateNewCapacity(newSize)); // Have to cast here because of compiler inference problems. for (Iterator it = map.entrySet().iterator(); it.hasNext();) { Entry<? extends K, ? extends V> entry = (Entry<? extends K, ? extends V>) it.next(); put(entry.getKey(), entry.getValue()); } }
/** * Puts all the values from the specified map into this map. * <p/> * This implementation iterates around the specified map and * uses {@link #put(Object, Object)}. * * @param map the map to add * @throws NullPointerException if the map is null */ public void putAll(Map<? extends K, ? extends V> map) { int mapSize = map.size(); if (mapSize == 0) { return; } int newSize = (int) ((size + mapSize) / loadFactor + 1); ensureCapacity(calculateNewCapacity(newSize)); // Have to cast here because of compiler inference problems. for (Iterator it = map.entrySet().iterator(); it.hasNext();) { Map.Entry<? extends K, ? extends V> entry = (Map.Entry<? extends K, ? extends V>) it.next(); put(entry.getKey(), entry.getValue()); } }
/** * Puts all the values from the specified map into this map. * <p/> * This implementation iterates around the specified map and * uses {@link #put(Object, Object)}. * * @param map the map to add * @throws NullPointerException if the map is null */ public void putAll(Map<? extends K, ? extends V> map) { int mapSize = map.size(); if (mapSize == 0) { return; } int newSize = (int) ((size + mapSize) / loadFactor + 1); ensureCapacity(calculateNewCapacity(newSize)); // Have to cast here because of compiler inference problems. for (Iterator it = map.entrySet().iterator(); it.hasNext();) { Map.Entry<? extends K, ? extends V> entry = (Map.Entry<? extends K, ? extends V>) it.next(); put(entry.getKey(), entry.getValue()); } }
K key = (K) in.readObject(); V value = (V) in.readObject(); put(key, value);
K key = (K) in.readObject(); V value = (V) in.readObject(); put(key, value);
K key = (K) in.readObject(); V value = (V) in.readObject(); put(key, value);