java.lang.Object
com.aoapps.collections.MinimalMap
MinimalMap provides a set of static methods to dynamically choose the most
efficient Map implementation. The implementation of Map is changed as needed.
MinimalMap is most suited for building map-based data structures that use less
heap space than a pure HashMap-based solution.
Insertion order is maintained.
size=0: Collections.emptyMap()
size=1: Collections.singletonMap(java.lang.Object, java.lang.Object)
size=2: LinkedHashMap
- Author:
- AO Industries, Inc.
-
Method Summary
Modifier and TypeMethodDescriptionstatic <K,
V> boolean containsKey
(Map<K, V> map, K key) Deprecated.static <K,
V> Map <K, V> Performs a shallow copy of a map.static <K,
V> Map <K, V> emptyMap()
Gets the empty map representation.static <K,
V> V Deprecated.Since empty maps are no longer represented bynull
, invokeMap.get(java.lang.Object)
directly now.static <K,
V> Map <K, V> Puts a new element in a map, returning the (possibly new) map.static <K,
V> Map <K, V> Removes an element from a map, returning the (possibly new) map.static <K,
V> Map <K, V> unmodifiable
(Map<K, V> map) Gets an unmodifiable wrapper around this map.static <K,
V> Collection <V> Deprecated.Since empty maps are no longer represented bynull
, invokeMap.values()
directly now.static <K,
V> Collection <V> valuesCopy
(Map<K, V> map) Performs a shallow copy of the value collection.
-
Method Details
-
emptyMap
Gets the empty map representation. -
put
Puts a new element in a map, returning the (possibly new) map. -
remove
Removes an element from a map, returning the (possibly new) map. -
get
Deprecated.Since empty maps are no longer represented bynull
, invokeMap.get(java.lang.Object)
directly now.Gets an element from a map. -
containsKey
Deprecated.Since empty maps are no longer represented bynull
, invokeMap.containsKey(java.lang.Object)
directly now.Checks if a key is contained in the map. -
values
Deprecated.Since empty maps are no longer represented bynull
, invokeMap.values()
directly now.Gets the value collection. -
valuesCopy
Performs a shallow copy of the value collection. -
copy
Performs a shallow copy of a map. The map is assumed to have been created by MinimalMap and to be used through MinimalMap. -
unmodifiable
Gets an unmodifiable wrapper around this map. May or may not wrap this map itself.
-
null
, invokeMap.containsKey(java.lang.Object)
directly now.