java.util.HashMap , it avoids allocating an extra node object per entry and rather
keeps values always in a plain array. See EconomicMapImpl for implementation details and
exact thresholds when its representation changes.
It supports a null value, but it does not support adding or looking up a null
key. Operations get and put provide constant-time performance on average if
repeatedly performed. They can however trigger an operation growing or compressing the data
structure, which is linear in the number of elements. Iteration is also linear in the number of
elements.
The implementation is not synchronized. If multiple threads want to access the data structure, it
requires manual synchronization, for example using java.util.Collections#synchronizedMap .
There is also no extra precaution to detect concurrent modification while iterating.
Different strategies for the equality comparison can be configured by providing a
Equivalence configuration object.
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public static <K, V> EconomicMap | create()
Creates a new map that guarantees insertion order on the key set with the default
|
| public static <K, V> EconomicMap | create(int initialCapacity)
Creates a new map that guarantees insertion order on the key set with the default
|
| public static <K, V> EconomicMap | create(Equivalence strategy)
Creates a new map that guarantees insertion order on the key set with the given comparison strategy for keys. |
| public static <K, V> EconomicMap | create(UnmodifiableEconomicMap<K, V> m)
Creates a new map that guarantees insertion order on the key set with the default
|
| public static <K, V> EconomicMap | create(Equivalence strategy, UnmodifiableEconomicMap<K, V> m)
Creates a new map that guarantees insertion order on the key set and copies all elements from the specified existing map. |
| public static <K, V> EconomicMap | create(Equivalence strategy, int initialCapacity)
Creates a new map that guarantees insertion order on the key set and initializes with a specified capacity. |
| public static <K, V> MapCursor | |
| public static <K, V> EconomicMap | |
| public MapCursor | getEntries()
Redeclares org. Returns a |
| public static <K, V> EconomicMap | Returns: a map with the mappingthe key of the first mapping key1, V the value of the first mapping value1)Creates an |
| public static <K, V> EconomicMap | Returns: a map with two mappingsthe key of the first mapping key1, V the value of the first mapping value1, K the key of the second mapping key2, V the value of the second mapping value2)Creates an |
| public V | Returns: the previous value associated withkey, or null if there was no
mapping for key.Associates |
| public default void | |
| public default void | putAll(UnmodifiableEconomicMap<? extends K, ? extends V> other)
Copies all of the mappings from |
| public default V | Returns: the previous value associated with the specified key, ornull if there was no
mapping for the key. (A null return can also indicate that the map previously
associated null with the key, if the implementation supports null values.)key with which the specified value is to be associated key, V value to be associated with the specified key value)If the specified key is not already associated with a value (or is mapped to |
| public V | Returns: the previous value associated withkey, or null if there was no
mapping for key.Removes the mapping for |
| public void | replaceAll(BiFunction<? super K, ? super V, ? extends V> function)
Replaces each entry's value with the result of invoking |
| public static <K, V> EconomicMap |
| clear | back to summary |
|---|---|
| public void clear() Removes all of the mappings from this map. The map will be empty after this call returns.
| |
| create | back to summary |
|---|---|
| public static <K, V> EconomicMap Creates a new map that guarantees insertion order on the key set with the default
| |
| create | back to summary |
|---|---|
| public static <K, V> EconomicMap Creates a new map that guarantees insertion order on the key set with the default
| |
| create | back to summary |
|---|---|
| public static <K, V> EconomicMap Creates a new map that guarantees insertion order on the key set with the given comparison strategy for keys.
| |
| create | back to summary |
|---|---|
| public static <K, V> EconomicMap Creates a new map that guarantees insertion order on the key set with the default
| |
| create | back to summary |
|---|---|
| public static <K, V> EconomicMap Creates a new map that guarantees insertion order on the key set and copies all elements from the specified existing map.
| |
| create | back to summary |
|---|---|
| public static <K, V> EconomicMap Creates a new map that guarantees insertion order on the key set and initializes with a specified capacity.
| |
| emptyCursor | back to summary |
|---|---|
| public static <K, V> MapCursor Return an empty
| |
| emptyMap | back to summary |
|---|---|
| public static <K, V> EconomicMap Return an empty, unmodifiable
| |
| getEntries | back to summary |
|---|---|
| public MapCursor Redeclares org. Returns a
| |
| of | back to summary |
|---|---|
| public static <K, V> EconomicMap Creates an
| |
| of | back to summary |
|---|---|
| public static <K, V> EconomicMap Creates an
| |
| put | back to summary |
|---|---|
| public V put(K key, V value) Associates
| |
| putAll | back to summary |
|---|---|
| public default void putAll(EconomicMap<K, V> other) Copies all of the mappings from
| |
| putAll | back to summary |
|---|---|
| public default void putAll(UnmodifiableEconomicMap<? extends K, ? extends V> other) Copies all of the mappings from
| |
| putIfAbsent | back to summary |
|---|---|
| public default V putIfAbsent(K key, V value) If the specified key is not already associated with a value (or is mapped to
| |
| removeKey | back to summary |
|---|---|
| public V removeKey(K key) Removes the mapping for
| |
| replaceAll | back to summary |
|---|---|
| public void replaceAll(BiFunction<? super K, ? super V, ? extends V> function) Replaces each entry's value with the result of invoking
| |
| wrapMap | back to summary |
|---|---|
| public static <K, V> EconomicMap Wraps an existing
| |