@Test public void getTest() { UIntMap<String> map = new UIntMap<>(1); map.put(1, "2"); Assert.assertEquals("2", map.get(1)); Assert.assertNull(map.get(2)); map.put(1, "3"); Assert.assertEquals("3", map.get(1)); map = new UIntMap<>(); for (int i = 0; i < 100000; i++) { map.put(i, String.valueOf(i + 1)); } for (int i = 0; i < 100000; i++) { Assert.assertEquals(String.valueOf(i + 1), map.get(i)); } }
public T get(int key) { if (key < 0) { throw new IllegalArgumentException("Key cannot be negative: " + key); } int slot = hash(key) & modulo; while (true) { final int t = keys[slot]; if (t == EMPTY) { return null; } if (t == DELETED) { slot = (slot + 1) & modulo; continue; } if (t == key) { return values[slot]; } slot = (slot + 1) & modulo; } }
UIntMap extends UIntKeyHashBase implements Iterable<T> { public T get(int key) { if (key < 0) { throw new IllegalArgumentException("Key cannot be negative: " + key); } int slot = hash(key) & modulo; while (true) { final int t = keys[slot]; if (t == EMPTY) { return null; } if (t == DELETED) { slot = (slot + 1) & modulo; continue; } if (t == key) { return values[slot]; } slot = (slot + 1) & modulo; } } }
UIntMap extends UIntKeyHashBase implements Iterable<T> { public T get(int key) { if (key < 0) { throw new IllegalArgumentException("Key cannot be negative: " + key); } int slot = hash(key) & modulo; while (true) { final int t = keys[slot]; if (t == EMPTY) { return null; } if (t == DELETED) { slot = (slot + 1) & modulo; continue; } if (t == key) { return values[slot]; } slot = (slot + 1) & modulo; } } UIntMap();  UIntMap(int size); }
UIntMap extends UIntKeyHashBase implements Iterable<T> { public T get(int key) { if (key < 0) { throw new IllegalArgumentException("Key cannot be negative: " + key); } int slot = hash(key) & modulo; while (true) { final int t = keys[slot]; if (t == EMPTY) { return null; } if (t == DELETED) { slot = (slot + 1) & modulo; continue; } if (t == key) { return values[slot]; } slot = (slot + 1) & modulo; } } UIntMap();  UIntMap(int size); T get(int key); boolean containsKey(int key); void put(int key, T value); List<T> getValues(); @Override Iterator<T> iterator(); List<T> getValuesSortedByKey(); }
UIntMap extends UIntKeyHashBase implements Iterable<T> { public T get(int key) { if (key < 0) { throw new IllegalArgumentException("Key cannot be negative: " + key); } int slot = hash(key) & modulo; while (true) { final int t = keys[slot]; if (t == EMPTY) { return null; } if (t == DELETED) { slot = (slot + 1) & modulo; continue; } if (t == key) { return values[slot]; } slot = (slot + 1) & modulo; } } UIntMap();  UIntMap(int size); T get(int key); boolean containsKey(int key); void put(int key, T value); List<T> getValues(); @Override Iterator<T> iterator(); List<T> getValuesSortedByKey();  }