@Test public void getTest() { IntValueMap<Integer> table = new IntValueMap<>(); table.put(1, 2); Assert.assertEquals(2, table.get(1)); Assert.assertEquals(0, table.get(2)); table.put(1, 3); Assert.assertEquals(3, table.get(1)); table = new IntValueMap<>(); for (int i = 0; i < 1000; i++) { table.put(i, i + 1); } for (int i = 0; i < 1000; i++) { Assert.assertEquals(i + 1, table.get(i)); } }
public int get(T key) { if (key == null) { throw new IllegalArgumentException("Key cannot be null."); } int slot = hash(key) & modulo; while (true) { final T t = keys[slot]; if (t == null) { return 0; } if (t == TOMB_STONE) { slot = (slot + 1) & modulo; continue; } if (t.equals(key)) { return values[slot]; } slot = (slot + 1) & modulo; } }
IntValueMap extends HashBase<T> implements Iterable<T> { public int get(T key) { if (key == null) { throw new IllegalArgumentException("Key cannot be null."); } int slot = hash(key) & modulo; while (true) { final T t = keys[slot]; if (t == null) { return 0; } if (t == TOMB_STONE) { slot = (slot + 1) & modulo; continue; } if (t.equals(key)) { return values[slot]; } slot = (slot + 1) & modulo; } } }
IntValueMap extends HashBase<T> implements Iterable<T> { public int get(T key) { if (key == null) { throw new IllegalArgumentException("Key cannot be null."); } int slot = hash(key) & modulo; while (true) { final T t = keys[slot]; if (t == null) { return 0; } if (t == TOMB_STONE) { slot = (slot + 1) & modulo; continue; } if (t.equals(key)) { return values[slot]; } slot = (slot + 1) & modulo; } } IntValueMap();  IntValueMap(int size); }
IntValueMap extends HashBase<T> implements Iterable<T> { public int get(T key) { if (key == null) { throw new IllegalArgumentException("Key cannot be null."); } int slot = hash(key) & modulo; while (true) { final T t = keys[slot]; if (t == null) { return 0; } if (t == TOMB_STONE) { slot = (slot + 1) & modulo; continue; } if (t.equals(key)) { return values[slot]; } slot = (slot + 1) & modulo; } } 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 int get(T key) { if (key == null) { throw new IllegalArgumentException("Key cannot be null."); } int slot = hash(key) & modulo; while (true) { final T t = keys[slot]; if (t == null) { return 0; } if (t == TOMB_STONE) { slot = (slot + 1) & modulo; continue; } if (t.equals(key)) { return values[slot]; } slot = (slot + 1) & modulo; } } 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();  }