/** * Converts the flat map data to a map. */ private void convertToMap() { delegateMap = createDelegateMap(); switch (size) { // drop through case 3: delegateMap.put(key3, value3); case 2: delegateMap.put(key2, value2); case 1: delegateMap.put(key1, value1); case 0: break; default: throw new IllegalStateException("Invalid map index: " + size); } size = 0; hash1 = hash2 = hash3 = 0; key1 = key2 = key3 = null; value1 = value2 = value3 = null; }
/** * 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 */ @Override public V put(final K key, final 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)}. * <p> * It is private to allow the constructor to still call it * even when putAll is overriden. * * @param map the map to add * @throws NullPointerException if the map is null */ private void _putAll(final Map<? extends K, ? extends V> map) { final int mapSize = map.size(); if (mapSize == 0) { return; } final int newSize = (int) ((size + mapSize) / loadFactor + 1); ensureCapacity(calculateNewCapacity(newSize)); for (final Map.Entry<? extends K, ? extends V> entry: map.entrySet()) { put(entry.getKey(), entry.getValue()); } }
final K key = (K) in.readObject(); final V value = (V) in.readObject(); put(key, value);
private void putCache(Key topKey, Value topValue) { Value valueInCache = cache.get(topKey); valueInCache = valueInCache == null ? topValue : combiner.multiply(topKey, valueInCache, topValue); ppIn++; cache.put(topKey, valueInCache); }
iterCache = removeFromMapToEmit(null); ppIn++; cache.put(k, v); source.next(); } else {