@Test public void mapShouldSupportHashingConflicts() { for (int mod = 0; mod < 10; ++mod) { for (int sz = 1; sz <= 101; sz += 2) { IntObjectHashMap<String> map = new IntObjectHashMap<String>(sz); for (int i = 0; i < 100; ++i) { map.put(i * mod, ""); } } } }
@Override public V put(int key, V value) { int startIndex = hashIndex(key); int index = startIndex; for (;;) { if (values[index] == null) { keys[index] = key; values[index] = toInternal(value); growSize(); return null; } if (keys[index] == key) { V previousValue = values[index]; values[index] = toInternal(value); return toExternal(previousValue); } if ((index = probeNext(index)) == startIndex) { throw new IllegalStateException("Unable to insert"); } } }
IntObjectHashMap implements IntObjectMap<V>, Iterable<IntObjectMap.Entry<V>> { @Override public V put(int key, V value) { int startIndex = hashIndex(key); int index = startIndex; for (;;) { if (values[index] == null) { keys[index] = key; values[index] = toInternal(value); growSize(); return null; } if (keys[index] == key) { V previousValue = values[index]; values[index] = toInternal(value); return toExternal(previousValue); } if ((index = probeNext(index)) == startIndex) { throw new IllegalStateException("Unable to insert"); } } } }
IntObjectHashMap implements IntObjectMap<V>, Iterable<IntObjectMap.Entry<V>> { @Override public V put(int key, V value) { int startIndex = hashIndex(key); int index = startIndex; for (;;) { if (values[index] == null) { keys[index] = key; values[index] = toInternal(value); growSize(); return null; } if (keys[index] == key) { V previousValue = values[index]; values[index] = toInternal(value); return toExternal(previousValue); } if ((index = probeNext(index)) == startIndex) { throw new IllegalStateException("Unable to insert"); } } } IntObjectHashMap();  IntObjectHashMap(int initialCapacity);  IntObjectHashMap(int initialCapacity, float loadFactor); }
IntObjectHashMap implements IntObjectMap<V>, Iterable<IntObjectMap.Entry<V>> { @Override public V put(int key, V value) { int startIndex = hashIndex(key); int index = startIndex; for (;;) { if (values[index] == null) { keys[index] = key; values[index] = toInternal(value); growSize(); return null; } if (keys[index] == key) { V previousValue = values[index]; values[index] = toInternal(value); return toExternal(previousValue); } if ((index = probeNext(index)) == startIndex) { throw new IllegalStateException("Unable to insert"); } } } IntObjectHashMap();  IntObjectHashMap(int initialCapacity);  IntObjectHashMap(int initialCapacity, float loadFactor); @Override V get(int key); @Override V put(int key, V value); @Override void putAll(IntObjectMap<V> sourceMap); @Override V remove(int key); @Override int size(); @Override boolean isEmpty(); @Override void clear(); @Override boolean containsKey(int key); @Override boolean containsValue(V value); @Override Iterable<Entry<V>> entries(); @Override Iterator<Entry<V>> iterator(); @Override int[] keys(); @Override V[] values(Class<V> clazz); @Override Collection<V> values(); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString(); }
IntObjectHashMap implements IntObjectMap<V>, Iterable<IntObjectMap.Entry<V>> { @Override public V put(int key, V value) { int startIndex = hashIndex(key); int index = startIndex; for (;;) { if (values[index] == null) { keys[index] = key; values[index] = toInternal(value); growSize(); return null; } if (keys[index] == key) { V previousValue = values[index]; values[index] = toInternal(value); return toExternal(previousValue); } if ((index = probeNext(index)) == startIndex) { throw new IllegalStateException("Unable to insert"); } } } IntObjectHashMap();  IntObjectHashMap(int initialCapacity);  IntObjectHashMap(int initialCapacity, float loadFactor); @Override V get(int key); @Override V put(int key, V value); @Override void putAll(IntObjectMap<V> sourceMap); @Override V remove(int key); @Override int size(); @Override boolean isEmpty(); @Override void clear(); @Override boolean containsKey(int key); @Override boolean containsValue(V value); @Override Iterable<Entry<V>> entries(); @Override Iterator<Entry<V>> iterator(); @Override int[] keys(); @Override V[] values(Class<V> clazz); @Override Collection<V> values(); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString();  }