- java.lang.Object
-
- com.aoapps.collections.MinimalMap
-
public class MinimalMap extends Object
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
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static <K,V>
booleancontainsKey(Map<K,V> map, K key)Deprecated.Since empty maps are no longer represented bynull, invokeMap.containsKey(java.lang.Object)directly now.static <K,V>
Map<K,V>copy(Map<K,V> map)Performs a shallow copy of a map.static <K,V>
Map<K,V>emptyMap()Gets the empty map representation.static <K,V>
Vget(Map<K,V> map, K key)Deprecated.Since empty maps are no longer represented bynull, invokeMap.get(java.lang.Object)directly now.static <K,V>
Map<K,V>put(Map<K,V> map, K key, V value)Puts a new element in a map, returning the (possibly new) map.static <K,V>
Map<K,V>remove(Map<K,V> map, K key)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>values(Map<K,V> map)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 Detail
-
emptyMap
public static <K,V> Map<K,V> emptyMap()
Gets the empty map representation.
-
put
public static <K,V> Map<K,V> put(Map<K,V> map, K key, V value)
Puts a new element in a map, returning the (possibly new) map.
-
remove
public static <K,V> Map<K,V> remove(Map<K,V> map, K key)
Removes an element from a map, returning the (possibly new) map.
-
get
@Deprecated public static <K,V> V get(Map<K,V> map, K key)
Deprecated.Since empty maps are no longer represented bynull, invokeMap.get(java.lang.Object)directly now.Gets an element from a map.
-
containsKey
@Deprecated public static <K,V> boolean containsKey(Map<K,V> map, K key)
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 public static <K,V> Collection<V> values(Map<K,V> map)
Deprecated.Since empty maps are no longer represented bynull, invokeMap.values()directly now.Gets the value collection.
-
valuesCopy
public static <K,V> Collection<V> valuesCopy(Map<K,V> map)
Performs a shallow copy of the value collection.
-
copy
public static <K,V> Map<K,V> copy(Map<K,V> map)
Performs a shallow copy of a map. The map is assumed to have been created by MinimalMap and to be used through MinimalMap.
-
-