@Test public void testAdd(){ Assert.assertEquals(0, shortMap.size); shortMap.put((short) 123, "Example123"); Assert.assertEquals(1, shortMap.size); shortMap.put((short) 34, "Example34"); Assert.assertEquals(2, shortMap.size); shortMap.put((short) 0, "Example0"); Assert.assertEquals(3, shortMap.size); Assert.assertEquals("Example123", shortMap.put((short) 123, "NewExample123")); Assert.assertEquals(3, shortMap.size); }
public V put (short key, V value) { if (key == 0) { V oldValue = zeroValue; zeroValue = value; if (!hasZeroValue) { hasZeroValue = true; size++; } return oldValue; } short[] keyTable = this.keyTable; int index1 = (int)(key & mask); short key1 = keyTable[index1]; if (key1 == key) { V oldValue = valueTable[index1]; valueTable[index1] = value; return oldValue; } int index2 = hash2(key); short key2 = keyTable[index2]; if (key2 == key) { V oldValue = valueTable[index2]; valueTable[index2] = value; return oldValue; } int index3 = hash3(key); short key3 = keyTable[index3]; if (key3 == key) { V oldValue = valueTable[index3]; valueTable[index3] = value; return oldValue; } for (int i = capacity, n = i + stashSize; i < n; i++) { if (keyTable[i] == key) { V oldValue = valueTable[i]; valueTable[i] = value; return oldValue; } } if (key1 == EMPTY) { keyTable[index1] = key; valueTable[index1] = value; if (size++ >= threshold) resize(capacity << 1); return null; } if (key2 == EMPTY) { keyTable[index2] = key; valueTable[index2] = value; if (size++ >= threshold) resize(capacity << 1); return null; } if (key3 == EMPTY) { keyTable[index3] = key; valueTable[index3] = value; if (size++ >= threshold) resize(capacity << 1); return null; } push(key, value, index1, key1, index2, key2, index3, key3); return null; }
ShortMap implements Iterable<ShortMap.Entry<V>> { public V put (short key, V value) { if (key == 0) { V oldValue = zeroValue; zeroValue = value; if (!hasZeroValue) { hasZeroValue = true; size++; } return oldValue; } short[] keyTable = this.keyTable; int index1 = (int)(key & mask); short key1 = keyTable[index1]; if (key1 == key) { V oldValue = valueTable[index1]; valueTable[index1] = value; return oldValue; } int index2 = hash2(key); short key2 = keyTable[index2]; if (key2 == key) { V oldValue = valueTable[index2]; valueTable[index2] = value; return oldValue; } int index3 = hash3(key); short key3 = keyTable[index3]; if (key3 == key) { V oldValue = valueTable[index3]; valueTable[index3] = value; return oldValue; } for (int i = capacity, n = i + stashSize; i < n; i++) { if (keyTable[i] == key) { V oldValue = valueTable[i]; valueTable[i] = value; return oldValue; } } if (key1 == EMPTY) { keyTable[index1] = key; valueTable[index1] = value; if (size++ >= threshold) resize(capacity << 1); return null; } if (key2 == EMPTY) { keyTable[index2] = key; valueTable[index2] = value; if (size++ >= threshold) resize(capacity << 1); return null; } if (key3 == EMPTY) { keyTable[index3] = key; valueTable[index3] = value; if (size++ >= threshold) resize(capacity << 1); return null; } push(key, value, index1, key1, index2, key2, index3, key3); return null; } }
ShortMap implements Iterable<ShortMap.Entry<V>> { public V put (short key, V value) { if (key == 0) { V oldValue = zeroValue; zeroValue = value; if (!hasZeroValue) { hasZeroValue = true; size++; } return oldValue; } short[] keyTable = this.keyTable; int index1 = (int)(key & mask); short key1 = keyTable[index1]; if (key1 == key) { V oldValue = valueTable[index1]; valueTable[index1] = value; return oldValue; } int index2 = hash2(key); short key2 = keyTable[index2]; if (key2 == key) { V oldValue = valueTable[index2]; valueTable[index2] = value; return oldValue; } int index3 = hash3(key); short key3 = keyTable[index3]; if (key3 == key) { V oldValue = valueTable[index3]; valueTable[index3] = value; return oldValue; } for (int i = capacity, n = i + stashSize; i < n; i++) { if (keyTable[i] == key) { V oldValue = valueTable[i]; valueTable[i] = value; return oldValue; } } if (key1 == EMPTY) { keyTable[index1] = key; valueTable[index1] = value; if (size++ >= threshold) resize(capacity << 1); return null; } if (key2 == EMPTY) { keyTable[index2] = key; valueTable[index2] = value; if (size++ >= threshold) resize(capacity << 1); return null; } if (key3 == EMPTY) { keyTable[index3] = key; valueTable[index3] = value; if (size++ >= threshold) resize(capacity << 1); return null; } push(key, value, index1, key1, index2, key2, index3, key3); return null; } ShortMap();  ShortMap(int initialCapacity);  ShortMap(int initialCapacity, float loadFactor);  ShortMap(ShortMap<? extends V> map); }
ShortMap implements Iterable<ShortMap.Entry<V>> { public V put (short key, V value) { if (key == 0) { V oldValue = zeroValue; zeroValue = value; if (!hasZeroValue) { hasZeroValue = true; size++; } return oldValue; } short[] keyTable = this.keyTable; int index1 = (int)(key & mask); short key1 = keyTable[index1]; if (key1 == key) { V oldValue = valueTable[index1]; valueTable[index1] = value; return oldValue; } int index2 = hash2(key); short key2 = keyTable[index2]; if (key2 == key) { V oldValue = valueTable[index2]; valueTable[index2] = value; return oldValue; } int index3 = hash3(key); short key3 = keyTable[index3]; if (key3 == key) { V oldValue = valueTable[index3]; valueTable[index3] = value; return oldValue; } for (int i = capacity, n = i + stashSize; i < n; i++) { if (keyTable[i] == key) { V oldValue = valueTable[i]; valueTable[i] = value; return oldValue; } } if (key1 == EMPTY) { keyTable[index1] = key; valueTable[index1] = value; if (size++ >= threshold) resize(capacity << 1); return null; } if (key2 == EMPTY) { keyTable[index2] = key; valueTable[index2] = value; if (size++ >= threshold) resize(capacity << 1); return null; } if (key3 == EMPTY) { keyTable[index3] = key; valueTable[index3] = value; if (size++ >= threshold) resize(capacity << 1); return null; } push(key, value, index1, key1, index2, key2, index3, key3); return null; } ShortMap();  ShortMap(int initialCapacity);  ShortMap(int initialCapacity, float loadFactor);  ShortMap(ShortMap<? extends V> map); V put(short key, V value); void putAll(ShortMap<V> map); V get(short key); V get(short key, V defaultValue); V remove(short key); void shrink(int maximumCapacity); void clear(int maximumCapacity); void clear(); boolean containsValue(Object value, boolean identity); boolean containsKey(short key); short findKey(Object value, boolean identity, short notFound); void ensureCapacity(int additionalCapacity); int hashCode(); boolean equals(Object obj); String toString(); Iterator<Entry<V>> iterator(); Entries<V> entries(); Values<V> values(); Keys keys(); }
ShortMap implements Iterable<ShortMap.Entry<V>> { public V put (short key, V value) { if (key == 0) { V oldValue = zeroValue; zeroValue = value; if (!hasZeroValue) { hasZeroValue = true; size++; } return oldValue; } short[] keyTable = this.keyTable; int index1 = (int)(key & mask); short key1 = keyTable[index1]; if (key1 == key) { V oldValue = valueTable[index1]; valueTable[index1] = value; return oldValue; } int index2 = hash2(key); short key2 = keyTable[index2]; if (key2 == key) { V oldValue = valueTable[index2]; valueTable[index2] = value; return oldValue; } int index3 = hash3(key); short key3 = keyTable[index3]; if (key3 == key) { V oldValue = valueTable[index3]; valueTable[index3] = value; return oldValue; } for (int i = capacity, n = i + stashSize; i < n; i++) { if (keyTable[i] == key) { V oldValue = valueTable[i]; valueTable[i] = value; return oldValue; } } if (key1 == EMPTY) { keyTable[index1] = key; valueTable[index1] = value; if (size++ >= threshold) resize(capacity << 1); return null; } if (key2 == EMPTY) { keyTable[index2] = key; valueTable[index2] = value; if (size++ >= threshold) resize(capacity << 1); return null; } if (key3 == EMPTY) { keyTable[index3] = key; valueTable[index3] = value; if (size++ >= threshold) resize(capacity << 1); return null; } push(key, value, index1, key1, index2, key2, index3, key3); return null; } ShortMap();  ShortMap(int initialCapacity);  ShortMap(int initialCapacity, float loadFactor);  ShortMap(ShortMap<? extends V> map); V put(short key, V value); void putAll(ShortMap<V> map); V get(short key); V get(short key, V defaultValue); V remove(short key); void shrink(int maximumCapacity); void clear(int maximumCapacity); void clear(); boolean containsValue(Object value, boolean identity); boolean containsKey(short key); short findKey(Object value, boolean identity, short notFound); void ensureCapacity(int additionalCapacity); int hashCode(); boolean equals(Object obj); String toString(); Iterator<Entry<V>> iterator(); Entries<V> entries(); Values<V> values(); Keys keys(); public int size; }