FastMap implements Map<K,V>, Serializable, Cloneable { @Override public V put(K key, V value) { Preconditions.checkNotNull(key); Preconditions.checkNotNull(value); if (numSlotsUsed * loadFactor >= keys.length) { if (numEntries * loadFactor >= numSlotsUsed) { growAndRehash(); } else { rehash(); } } int index = findForAdd(key); if (keys[index] == key) { V oldValue = values[index]; values[index] = value; return oldValue; } if (countingAccesses && numEntries >= maxSize) { clearStaleEntry(index); } keys[index] = key; values[index] = value; numEntries++; numSlotsUsed++; return null; } FastMap();  FastMap(int size);  FastMap(Map<K,V> other);  FastMap(int size, float loadFactor);  FastMap(int size, int maxSize);  FastMap(int size, int maxSize, float loadFactor); @Override V get(Object key); @Override int size(); @Override boolean isEmpty(); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @Override V put(K key, V value); @Override void putAll(Map<? extends K,? extends V> map); @Override V remove(Object key); @Override void clear(); @Override Set<K> keySet(); @Override Collection<V> values(); @Override Set<Entry<K,V>> entrySet(); void rehash(); @Override FastMap<K,V> clone(); @Override int hashCode(); @Override boolean equals(Object other); @Override String toString(); static final int NO_MAX_SIZE; }
@Test(expected = NullPointerException.class) public void testNull2() { Map<String, String> map = new FastMap<String, String>(); map.put("foo", null); }
@Test(expected = NullPointerException.class) public void testNull2() { Map<String, String> map = new FastMap<>(); map.put("foo", null); }