CompactHashMapClass { public boolean containsKey(CompactHashMap<K, V> map, Object key) { K nonNullKey = maskNull((K) key); final Integer slot = key2slot.get(nonNullKey); if (slot == null) return getDefaultValues().containsKey(nonNullKey); return getValueFromSlot(map, slot) != REMOVED_OBJECT; } CompactHashMapClass(com.github.andrewoma.dexx.collection.Map<K, Integer> key2slot); V get(CompactHashMap<K, V> map, K key); V put(CompactHashMap<K, V> map, K key, Object value); int size(CompactHashMap<K, V> map); boolean containsKey(CompactHashMap<K, V> map, Object key); Set<K> keySet(CompactHashMap<K, V> map); Set<V> values(CompactHashMap<K, V> map); Set<Map.Entry<K, V>> entrySet(CompactHashMap<K, V> map); void serialize(final CompactHashMap<K, V> map, final ObjectOutputStream s); static void deserialize(CompactHashMap<K, V> map, ObjectInputStream s); static final CompactHashMapClass EMPTY; static final String REMOVED_OBJECT; }
@Test public void containsKeyOnNonExistingKey() { CompactHashMapDefaultValues.add("k1", "v1"); CompactHashMap<String, Object> map = new CompactHashMap<String, Object>(); Assert.assertFalse(map.containsKey("abcd")); Assert.assertFalse(map.containsKey("k1")); }