@Test public void putTest() { IntValueMap<String> table = new IntValueMap<>(); table.put("foo", 1); Assert.assertEquals(1, table.size()); table.put("foo", 2); Assert.assertEquals(1, table.size()); table = new IntValueMap<>(); for (int i = 0; i < 1000; i++) { table.put(String.valueOf(i), i + 1); Assert.assertEquals(i + 1, table.size()); } table = new IntValueMap<>(); for (int i = 0; i < 1000; i++) { table.put(String.valueOf(i), i + 1); table.put(String.valueOf(i), i + 1); Assert.assertEquals(i + 1, table.size()); } }
public void put(T key, int value) { if (key == null) { throw new IllegalArgumentException("Key cannot be null."); } if (keyCount + removeCount == threshold) { expand(); } int loc = locate(key); if (loc >= 0) { values[loc] = value; } else { loc = -loc - 1; keys[loc] = key; values[loc] = value; keyCount++; } }
IntValueMap extends HashBase<T> implements Iterable<T> { public void put(T key, int value) { if (key == null) { throw new IllegalArgumentException("Key cannot be null."); } if (keyCount + removeCount == threshold) { expand(); } int loc = locate(key); if (loc >= 0) { values[loc] = value; } else { loc = -loc - 1; keys[loc] = key; values[loc] = value; keyCount++; } } }
IntValueMap extends HashBase<T> implements Iterable<T> { public void put(T key, int value) { if (key == null) { throw new IllegalArgumentException("Key cannot be null."); } if (keyCount + removeCount == threshold) { expand(); } int loc = locate(key); if (loc >= 0) { values[loc] = value; } else { loc = -loc - 1; keys[loc] = key; values[loc] = value; keyCount++; } } IntValueMap();  IntValueMap(int size); }
IntValueMap extends HashBase<T> implements Iterable<T> { public void put(T key, int value) { if (key == null) { throw new IllegalArgumentException("Key cannot be null."); } if (keyCount + removeCount == threshold) { expand(); } int loc = locate(key); if (loc >= 0) { values[loc] = value; } else { loc = -loc - 1; keys[loc] = key; values[loc] = value; keyCount++; } } IntValueMap();  IntValueMap(int size); int addOrIncrement(T key); void addOrIncrementAll(Iterable<T> keys); int get(T key); int decrement(T key); int incrementByAmount(T key, int amount); void put(T key, int value); int[] copyOfValues(); List<Entry<T>> getAsEntryList(); Iterator<Entry<T>> entryIterator(); Iterable<Entry<T>> iterableEntries(); }
IntValueMap extends HashBase<T> implements Iterable<T> { public void put(T key, int value) { if (key == null) { throw new IllegalArgumentException("Key cannot be null."); } if (keyCount + removeCount == threshold) { expand(); } int loc = locate(key); if (loc >= 0) { values[loc] = value; } else { loc = -loc - 1; keys[loc] = key; values[loc] = value; keyCount++; } } IntValueMap();  IntValueMap(int size); int addOrIncrement(T key); void addOrIncrementAll(Iterable<T> keys); int get(T key); int decrement(T key); int incrementByAmount(T key, int amount); void put(T key, int value); int[] copyOfValues(); List<Entry<T>> getAsEntryList(); Iterator<Entry<T>> entryIterator(); Iterable<Entry<T>> iterableEntries();  }