@Test public void testFindKey(){ Assert.assertEquals(256, shortMap.findKey("Example0", false, (short) 256)); Assert.assertEquals(256, shortMap.findKey("Example34", false, (short) 256)); Assert.assertEquals(256, shortMap.findKey("NewExample123", false, (short) 256)); Assert.assertEquals(256, shortMap.findKey("ThisValueShouldNotBePresent", false, (short) 256)); testAdd(); Assert.assertEquals(0, shortMap.findKey("Example0", false, (short) 256)); Assert.assertEquals(34, shortMap.findKey("Example34", false, (short) 256)); Assert.assertEquals(123, shortMap.findKey("NewExample123", false, (short) 256)); Assert.assertEquals(256, shortMap.findKey("ThisValueShouldNotBePresent", false, (short) 256)); shortMap.clear(); Assert.assertEquals(256, shortMap.findKey("Example0", false, (short) 256)); Assert.assertEquals(256, shortMap.findKey("Example34", false, (short) 256)); Assert.assertEquals(256, shortMap.findKey("NewExample123", false, (short) 256)); Assert.assertEquals(256, shortMap.findKey("ThisValueShouldNotBePresent", false, (short) 256)); }
public short findKey (Object value, boolean identity, short notFound) { V[] valueTable = this.valueTable; if (value == null) { if (hasZeroValue && zeroValue == null) return 0; short[] keyTable = this.keyTable; for (int i = capacity + stashSize; i-- > 0;) if (keyTable[i] != EMPTY && valueTable[i] == null) return keyTable[i]; } else if (identity) { if (value == zeroValue) return 0; for (int i = capacity + stashSize; i-- > 0;) if (valueTable[i] == value) return keyTable[i]; } else { if (hasZeroValue && value.equals(zeroValue)) return 0; for (int i = capacity + stashSize; i-- > 0;) if (value.equals(valueTable[i])) return keyTable[i]; } return notFound; }
ShortMap implements Iterable<ShortMap.Entry<V>> { public short findKey (Object value, boolean identity, short notFound) { V[] valueTable = this.valueTable; if (value == null) { if (hasZeroValue && zeroValue == null) return 0; short[] keyTable = this.keyTable; for (int i = capacity + stashSize; i-- > 0;) if (keyTable[i] != EMPTY && valueTable[i] == null) return keyTable[i]; } else if (identity) { if (value == zeroValue) return 0; for (int i = capacity + stashSize; i-- > 0;) if (valueTable[i] == value) return keyTable[i]; } else { if (hasZeroValue && value.equals(zeroValue)) return 0; for (int i = capacity + stashSize; i-- > 0;) if (value.equals(valueTable[i])) return keyTable[i]; } return notFound; } }
ShortMap implements Iterable<ShortMap.Entry<V>> { public short findKey (Object value, boolean identity, short notFound) { V[] valueTable = this.valueTable; if (value == null) { if (hasZeroValue && zeroValue == null) return 0; short[] keyTable = this.keyTable; for (int i = capacity + stashSize; i-- > 0;) if (keyTable[i] != EMPTY && valueTable[i] == null) return keyTable[i]; } else if (identity) { if (value == zeroValue) return 0; for (int i = capacity + stashSize; i-- > 0;) if (valueTable[i] == value) return keyTable[i]; } else { if (hasZeroValue && value.equals(zeroValue)) return 0; for (int i = capacity + stashSize; i-- > 0;) if (value.equals(valueTable[i])) return keyTable[i]; } return notFound; } ShortMap();  ShortMap(int initialCapacity);  ShortMap(int initialCapacity, float loadFactor);  ShortMap(ShortMap<? extends V> map); }
ShortMap implements Iterable<ShortMap.Entry<V>> { public short findKey (Object value, boolean identity, short notFound) { V[] valueTable = this.valueTable; if (value == null) { if (hasZeroValue && zeroValue == null) return 0; short[] keyTable = this.keyTable; for (int i = capacity + stashSize; i-- > 0;) if (keyTable[i] != EMPTY && valueTable[i] == null) return keyTable[i]; } else if (identity) { if (value == zeroValue) return 0; for (int i = capacity + stashSize; i-- > 0;) if (valueTable[i] == value) return keyTable[i]; } else { if (hasZeroValue && value.equals(zeroValue)) return 0; for (int i = capacity + stashSize; i-- > 0;) if (value.equals(valueTable[i])) return keyTable[i]; } return notFound; } 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 short findKey (Object value, boolean identity, short notFound) { V[] valueTable = this.valueTable; if (value == null) { if (hasZeroValue && zeroValue == null) return 0; short[] keyTable = this.keyTable; for (int i = capacity + stashSize; i-- > 0;) if (keyTable[i] != EMPTY && valueTable[i] == null) return keyTable[i]; } else if (identity) { if (value == zeroValue) return 0; for (int i = capacity + stashSize; i-- > 0;) if (valueTable[i] == value) return keyTable[i]; } else { if (hasZeroValue && value.equals(zeroValue)) return 0; for (int i = capacity + stashSize; i-- > 0;) if (value.equals(valueTable[i])) return keyTable[i]; } return notFound; } 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; }