Package ej.basictool.map
Class IdentityPackedMap<K,V>
- java.lang.Object
-
- ej.basictool.map.AbstractPackedMap<K,V>
-
- ej.basictool.map.IdentityPackedMap<K,V>
-
- Type Parameters:
K- the type of keys maintained by this map.V- the type of mapped values.
public class IdentityPackedMap<K,V> extends AbstractPackedMap<K,V>
This class implements theAbstractPackedMapclass, using reference-equality when comparing keys. In other words, in an IdentityPackedMap, two keys k1 and k2 are considered equal if and only if(k1==k2).
-
-
Field Summary
-
Fields inherited from class ej.basictool.map.AbstractPackedMap
keysValues
-
-
Constructor Summary
Constructors Constructor Description IdentityPackedMap()Constructs an empty map.IdentityPackedMap(IdentityPackedMap<K,V> map)Constructs a map with the same mappings as the specified map.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Objectclone()Returns a shallow copy of this map instance: the keys and values themselves are not cloned.protected booleanisSame(Object key, Object candidateKey)Checks whether two keys are equal or not.-
Methods inherited from class ej.basictool.map.AbstractPackedMap
clear, containsKey, containsUnwrappedKey, containsValue, equals, get, getKeyHashCode, getWrappedKeyHashCode, hashCode, isEmpty, keySet, put, remove, size, unwrapKey, values, wrapKey
-
-
-
-
Constructor Detail
-
IdentityPackedMap
public IdentityPackedMap()
Constructs an empty map.
-
IdentityPackedMap
public IdentityPackedMap(IdentityPackedMap<K,V> map)
Constructs a map with the same mappings as the specified map.- Parameters:
map- the map whose mappings are to be placed in this map.- Throws:
NullPointerException- if the specified map isnull.
-
-
Method Detail
-
clone
public Object clone()
Description copied from class:AbstractPackedMapReturns a shallow copy of this map instance: the keys and values themselves are not cloned.- Specified by:
clonein classAbstractPackedMap<K,V>- Returns:
- a shallow copy of this map
- See Also:
Cloneable
-
isSame
protected boolean isSame(Object key, @Nullable Object candidateKey)
Description copied from class:AbstractPackedMapChecks whether two keys are equal or not. The key must not benull.- Specified by:
isSamein classAbstractPackedMap<K,V>- Parameters:
key- the key searched in the map.candidateKey- the key in the map to compare with. Can benullif and only ifAbstractPackedMap.unwrapKey(Object)implementation can returnnull.- Returns:
trueif the two keys are equal,falseotherwise.
-
-