Package pascal.taie.util.collection
Class AbstractHybridMap<K,V>
java.lang.Object
java.util.AbstractMap<K,V>
pascal.taie.util.collection.AbstractHybridMap<K,V>
- Type Parameters:
K
- type of keysV
- type of values
- All Implemented Interfaces:
Serializable
,Map<K,
V>
- Direct Known Subclasses:
HybridHashMap
This map supports hybrid of two map implementations, where one is
efficient for small map and another one is efficient for large map.
When the number of mappings contained in this map succeeds a threshold, it will automatically upgrade the map implementation to the one that is efficient for large map. Moreover, empty maps and singleton maps are represented with just a reference.
Keys added to this map cannot be null.
By default, this set use ArrayMap
for small map.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K extends Object,
V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object, V extends Object> -
Constructor Summary
ModifierConstructorDescriptionprotected
Constructs a new empty hybrid map.AbstractHybridMap
(Map<K, V> m) Constructs a new hybrid map from the given map. -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
boolean
containsKey
(Object key) boolean
containsValue
(Object value) entrySet()
boolean
protected int
int
hashCode()
boolean
isEmpty()
keySet()
newLargeMap
(int initialCapacity) Creates a large map.Creates a small map.void
int
size()
values()
Methods inherited from class java.util.AbstractMap
clone, toString
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Constructor Details
-
AbstractHybridMap
protected AbstractHybridMap()Constructs a new empty hybrid map. -
AbstractHybridMap
Constructs a new hybrid map from the given map.
-
-
Method Details
-
getThreshold
protected int getThreshold()- Returns:
- the threshold between sizes of small map and large map. When number of mappings exceeds the threshold, map should be upgraded to large map.
-
newSmallMap
Creates a small map. -
newLargeMap
Creates a large map.- Parameters:
initialCapacity
- initial capacity of the resulting map.
-
clear
public void clear() -
containsKey
- Specified by:
containsKey
in interfaceMap<K,
V> - Overrides:
containsKey
in classAbstractMap<K,
V>
-
containsValue
- Specified by:
containsValue
in interfaceMap<K,
V> - Overrides:
containsValue
in classAbstractMap<K,
V>
-
get
-
put
-
putAll
-
remove
-
size
public int size() -
isEmpty
public boolean isEmpty() -
values
-
entrySet
-
keySet
-
equals
-
hashCode
public int hashCode()
-