Top Constructors Methods
org.eclipse.collections.impl.map.fixed

pack-priv abstract Class AbstractMemoryEfficientMutableMap<K, V>

extends AbstractMutableMap<K, V>
implements FixedSizeMap<K, V>
Class Inheritance
All Implemented Interfaces
org.eclipse.collections.api.map.FixedSizeMap, org.eclipse.collections.api.map.MutableMap, java.lang.Cloneable, org.eclipse.collections.api.map.UnsortedMapIterable, org.eclipse.collections.api.map.MapIterable, org.eclipse.collections.api.RichIterable, org.eclipse.collections.api.InternalIterable, java.lang.Iterable, org.eclipse.collections.api.map.MutableMapIterable, java.util.Map
Known Direct Subclasses
org.eclipse.collections.impl.map.fixed.DoubletonMap, org.eclipse.collections.impl.map.fixed.EmptyMap, org.eclipse.collections.impl.map.fixed.SingletonMap, org.eclipse.collections.impl.map.fixed.TripletonMap
Imports
java.util.Map, .Set, java.util.function.BiFunction, org.eclipse.collections.api.block.function.Function, .Function0, .Function2, org.eclipse.collections.api.block.predicate.Predicate2, org.eclipse.collections.api.block.procedure.Procedure, org.eclipse.collections.api.factory.Maps, org.eclipse.collections.api.map.FixedSizeMap, .MutableMap, org.eclipse.collections.api.tuple.Pair, org.eclipse.collections.impl.list.fixed.ArrayAdapter, org.eclipse.collections.impl.map.mutable.AbstractMutableMap, .UnifiedMap

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
clear()

Implements org.eclipse.collections.api.map.FixedSizeMap.clear, java.util.Map.clear.

Removes all of the mappings from this map (optional operation).

public abstract <K2, V2> FixedSizeMap<K2, V2>
public <E> MutableMap<K, V>
collectKeysAndValues(Iterable<E> iterable, Function<? super E, ? extends K> keyFunction, Function<? super E, ? extends V> valueFunction)

Implements org.eclipse.collections.api.map.MutableMap.collectKeysAndValues.

Adds all the entries derived from iterable to this.

public abstract <R> FixedSizeMap<R, V>
public abstract <R> FixedSizeMap<K, R>
public V
merge(K key, V value, BiFunction<? super V, ? super V, ? extends V> remappingFunction)

Overrides default java.util.Map.merge.

If the specified key is not already associated with a value or is associated with null, associates it with the given non-null value (optional operation).

public MutableMap<K, V>
newEmpty()

Implements org.eclipse.collections.api.map.MutableMap.newEmpty, org.eclipse.collections.api.map.MutableMapIterable.newEmpty.

Creates a new instance of the same type, using the default capacity and growth parameters.

public MutableMap<K, V>
newEmpty(int capacity)

Implements abstract org.eclipse.collections.impl.map.mutable.AbstractMutableMap.newEmpty.

Creates a new instance of the same type, using the given capacity and the default growth parameters.

public V
put(K key, V value)

Implements org.eclipse.collections.api.map.FixedSizeMap.put, java.util.Map.put.

Associates the specified value with the specified key in this map (optional operation).

public void
putAll(Map<? extends K, ? extends V> map)

Implements org.eclipse.collections.api.map.FixedSizeMap.putAll, java.util.Map.putAll.

Copies all of the mappings from the specified map to this map (optional operation).

public abstract FixedSizeMap<K, V>
reject(Predicate2<? super K, ? super V> predicate)

Redeclares org.eclipse.collections.api.map.MutableMap.reject, org.eclipse.collections.api.map.MutableMapIterable.reject, org.eclipse.collections.api.map.MapIterable.reject.

Overrides org.eclipse.collections.impl.map.mutable.AbstractMutableMap.reject.

For each key and value of the map the predicate is evaluated, if the result of the evaluation is false, that key and value are returned in a new map.

public V
remove(Object key)

Implements org.eclipse.collections.api.map.FixedSizeMap.remove, java.util.Map.remove.

Removes the mapping for a key from this map if it is present (optional operation).

public boolean
removeAllKeys(Set<? extends K> keys)

Overrides default org.eclipse.collections.api.map.MutableMapIterable.removeAllKeys.

Implements org.eclipse.collections.api.map.FixedSizeMap.removeAllKeys.

Remove entries from the map at the specified keys.

public boolean
removeIf(Predicate2<? super K, ? super V> predicate)

Overrides default org.eclipse.collections.api.map.MutableMapIterable.removeIf.

Implements org.eclipse.collections.api.map.FixedSizeMap.removeIf.

Remove an entry from the map if the predicate evaluates to true.

public V
public abstract FixedSizeMap<K, V>
select(Predicate2<? super K, ? super V> predicate)

Redeclares org.eclipse.collections.api.map.MutableMap.select, org.eclipse.collections.api.map.MutableMapIterable.select, org.eclipse.collections.api.map.MapIterable.select.

Overrides org.eclipse.collections.impl.map.mutable.AbstractMutableMap.select.

For each key and value of the map the predicate is evaluated, if the result of the evaluation is true, that key and value are returned in a new map.

public FixedSizeMap<K, V>
public V
updateValue(K key, Function0<? extends V> factory, Function<? super V, ? extends V> function)

Overrides org.eclipse.collections.impl.map.mutable.AbstractMutableMapIterable.updateValue.

Implements org.eclipse.collections.api.map.MutableMapIterable.updateValue.

Looks up the value associated with key, applies the function to it, and replaces the value.

public <P> V
updateValueWith(K key, Function0<? extends V> factory, Function2<? super V, ? super P, ? extends V> function, P parameter)

Overrides org.eclipse.collections.impl.map.mutable.AbstractMutableMapIterable.updateValueWith.

Implements org.eclipse.collections.api.map.MutableMapIterable.updateValueWith.

Same as updateValue(Object, Function0, Function) with a Function2 and specified parameter which is passed to the function.

public MutableMap<K, V>
public MutableMap<K, V>
withAllKeyValues(Iterable<? extends Pair<? extends K, ? extends V>> keyValues)

Overrides org.eclipse.collections.impl.map.mutable.AbstractMutableMap.withAllKeyValues.

Implements org.eclipse.collections.api.map.MutableMap.withAllKeyValues, org.eclipse.collections.api.map.MutableMapIterable.withAllKeyValues.

This method allows mutable, fixed size, and immutable maps the ability to add elements to their existing elements.

public MutableMap<K, V>
withoutAllKeys(Iterable<? extends K> keys)

Overrides org.eclipse.collections.impl.map.mutable.AbstractMutableMap.withoutAllKeys.

Implements org.eclipse.collections.api.map.MutableMap.withoutAllKeys, org.eclipse.collections.api.map.MutableMapIterable.withoutAllKeys.

This method allows mutable, fixed size, and immutable maps the ability to remove elements from their existing elements.

Inherited from org.eclipse.collections.impl.map.mutable.AbstractMutableMap:
asSynchronizedasUnmodifiableclonecollectcollectBooleancollectBytecollectCharcollectDoublecollectFloatcollectIfcollectIntcollectLongcollectShortcollectWithflatCollectflipgroupBygroupByEachgroupByUniqueKeypartitionpartitionWithrejectrejectWithreplaceAllselectselectInstancesOfselectWithtoImmutablewithKeyValuewithoutKeyzipzipWithIndex

Constructor Detail

AbstractMemoryEfficientMutableMapback to summary
pack-priv AbstractMemoryEfficientMutableMap()

Method Detail

clearback to summary
public void clear()

Implements org.eclipse.collections.api.map.FixedSizeMap.clear, java.util.Map.clear.

Doc from java.util.Map.clear.

Removes all of the mappings from this map (optional operation). The map will be empty after this call returns.

Annotations
@Override
collectback to summary
public abstract <K2, V2> FixedSizeMap<K2, V2> collect(Function2<? super K, ? super V, Pair<K2, V2>> function)

Redeclares org.eclipse.collections.api.map.MutableMap.collect, org.eclipse.collections.api.map.MutableMapIterable.collect, org.eclipse.collections.api.map.MapIterable.collect.

Overrides org.eclipse.collections.impl.map.mutable.AbstractMutableMapIterable.collect.

Doc from org.eclipse.collections.api.map.MapIterable.collect.

For each key and value of the map the function is evaluated. The results of these evaluations are returned in a new map. The map returned will use the values projected from the function rather than the original values.

MapIterable<String, String> collected =
    peopleByCity.collect((City city, Person person) -> Pair.of(city.getCountry(), person.getAddress().getCity()));
Annotations
@Override
collectKeysAndValuesback to summary
public <E> MutableMap<K, V> collectKeysAndValues(Iterable<E> iterable, Function<? super E, ? extends K> keyFunction, Function<? super E, ? extends V> valueFunction)

Implements org.eclipse.collections.api.map.MutableMap.collectKeysAndValues.

Doc from org.eclipse.collections.api.map.MutableMap.collectKeysAndValues.

Adds all the entries derived from iterable to this. The key and value for each entry is determined by applying the keyFunction and valueFunction to each item in collection. Any entry in map that has the same key as an entry in this will have its value replaced by that in map.

Annotations
@Override
collectKeysUniqueback to summary
public abstract <R> FixedSizeMap<R, V> collectKeysUnique(Function2<? super K, ? super V, ? extends R> function)

Redeclares org.eclipse.collections.api.map.MutableMap.collectKeysUnique, org.eclipse.collections.api.map.MutableMapIterable.collectKeysUnique, org.eclipse.collections.api.map.MapIterable.collectKeysUnique.

Overrides org.eclipse.collections.impl.map.mutable.AbstractMutableMap.collectKeysUnique.

Doc from org.eclipse.collections.api.map.MapIterable.collectKeysUnique.

For each key and value of the map the function is evaluated. The results of these evaluations are returned in a new map. The map returned will use the keys projected from the function rather than the original keys.

Annotations
@Override
collectValuesback to summary
public abstract <R> FixedSizeMap<K, R> collectValues(Function2<? super K, ? super V, ? extends R> function)

Redeclares org.eclipse.collections.api.map.MutableMap.collectValues, org.eclipse.collections.api.map.MutableMapIterable.collectValues, org.eclipse.collections.api.map.MapIterable.collectValues.

Overrides org.eclipse.collections.impl.map.mutable.AbstractMutableMap.collectValues.

Doc from org.eclipse.collections.api.map.MapIterable.collectValues.

For each key and value of the map the function is evaluated. The results of these evaluations are returned in a new map. The map returned will use the values projected from the function rather than the original values.

MapIterable<City, String> collected =
    peopleByCity.collectValues((City city, Person person) -> person.getFirstName() + " " + person.getLastName());
Annotations
@Override
mergeback to summary
public V merge(K key, V value, BiFunction<? super V, ? super V, ? extends V> remappingFunction)

Overrides default java.util.Map.merge.

Doc from java.util.Map.merge.

If the specified key is not already associated with a value or is associated with null, associates it with the given non-null value (optional operation). Otherwise, replaces the associated value with the results of the given remapping function, or removes if the result is null. This method may be of use when combining multiple mapped values for a key. For example, to either create or append a String msg to a value mapping:

 map.merge(key, msg, String::concat)

If the remapping function returns null, the mapping is removed. If the remapping function itself throws an (unchecked) exception, the exception is rethrown, and the current mapping is left unchanged.

The remapping function should not modify this map during computation.

Annotations
@Override
newEmptyback to summary
public MutableMap<K, V> newEmpty()

Implements org.eclipse.collections.api.map.MutableMap.newEmpty, org.eclipse.collections.api.map.MutableMapIterable.newEmpty.

Doc from org.eclipse.collections.api.map.MutableMapIterable.newEmpty.

Creates a new instance of the same type, using the default capacity and growth parameters.

Annotations
@Override
newEmptyback to summary
public MutableMap<K, V> newEmpty(int capacity)

Implements abstract org.eclipse.collections.impl.map.mutable.AbstractMutableMap.newEmpty.

Doc from org.eclipse.collections.impl.map.mutable.AbstractMutableMap.newEmpty.

Creates a new instance of the same type, using the given capacity and the default growth parameters.

Annotations
@Override
putback to summary
public V put(K key, V value)

Implements org.eclipse.collections.api.map.FixedSizeMap.put, java.util.Map.put.

Doc from java.util.Map.put.

Associates the specified value with the specified key in this map (optional operation). If the map previously contained a mapping for the key, the old value is replaced by the specified value. (A map m is said to contain a mapping for a key k if and only if m.containsKey(k) would return true.)

Annotations
@Override
putAllback to summary
public void putAll(Map<? extends K, ? extends V> map)

Implements org.eclipse.collections.api.map.FixedSizeMap.putAll, java.util.Map.putAll.

Doc from java.util.Map.putAll.

Copies all of the mappings from the specified map to this map (optional operation). The effect of this call is equivalent to that of calling put(k, v) on this map once for each mapping from key k to value v in the specified map. The behavior of this operation is undefined if the specified map is modified while the operation is in progress. If the specified map has a defined encounter order, processing of its mappings generally occurs in that order.

Annotations
@Override
rejectback to summary
public abstract FixedSizeMap<K, V> reject(Predicate2<? super K, ? super V> predicate)

Redeclares org.eclipse.collections.api.map.MutableMap.reject, org.eclipse.collections.api.map.MutableMapIterable.reject, org.eclipse.collections.api.map.MapIterable.reject.

Overrides org.eclipse.collections.impl.map.mutable.AbstractMutableMap.reject.

Doc from org.eclipse.collections.api.map.MapIterable.reject.

For each key and value of the map the predicate is evaluated, if the result of the evaluation is false, that key and value are returned in a new map.

MapIterable<City, Person> rejected =
    peopleByCity.reject((city, person) -> city.getName().equals("Anytown") && person.getLastName().equals("Smith"));
Annotations
@Override
removeback to summary
public V remove(Object key)

Implements org.eclipse.collections.api.map.FixedSizeMap.remove, java.util.Map.remove.

Doc from java.util.Map.remove.

Removes the mapping for a key from this map if it is present (optional operation). More formally, if this map contains a mapping from key k to value v such that Objects.equals(key, k), that mapping is removed. (The map can contain at most one such mapping.)

Returns the value to which this map previously associated the key, or null if the map contained no mapping for the key.

If this map permits null values, then a return value of null does not necessarily indicate that the map contained no mapping for the key; it's also possible that the map explicitly mapped the key to null.

The map will not contain a mapping for the specified key once the call returns.

Annotations
@Override
removeAllKeysback to summary
public boolean removeAllKeys(Set<? extends K> keys)

Overrides default org.eclipse.collections.api.map.MutableMapIterable.removeAllKeys.

Implements org.eclipse.collections.api.map.FixedSizeMap.removeAllKeys.

Doc from org.eclipse.collections.api.map.MutableMapIterable.removeAllKeys.

Remove entries from the map at the specified keys.

Annotations
@Override
removeIfback to summary
public boolean removeIf(Predicate2<? super K, ? super V> predicate)

Overrides default org.eclipse.collections.api.map.MutableMapIterable.removeIf.

Implements org.eclipse.collections.api.map.FixedSizeMap.removeIf.

Doc from org.eclipse.collections.api.map.MutableMapIterable.removeIf.

Remove an entry from the map if the predicate evaluates to true.

Annotations
@Override
removeKeyback to summary
public V removeKey(K key)

Implements org.eclipse.collections.api.map.FixedSizeMap.removeKey, org.eclipse.collections.api.map.MutableMapIterable.removeKey.

Doc from org.eclipse.collections.api.map.MutableMapIterable.removeKey.

Remove an entry from the map at the specified key.

Annotations
@Override
selectback to summary
public abstract FixedSizeMap<K, V> select(Predicate2<? super K, ? super V> predicate)

Redeclares org.eclipse.collections.api.map.MutableMap.select, org.eclipse.collections.api.map.MutableMapIterable.select, org.eclipse.collections.api.map.MapIterable.select.

Overrides org.eclipse.collections.impl.map.mutable.AbstractMutableMap.select.

Doc from org.eclipse.collections.api.map.MapIterable.select.

For each key and value of the map the predicate is evaluated, if the result of the evaluation is true, that key and value are returned in a new map.

MapIterable<City, Person> selected =
    peopleByCity.select((city, person) -> city.getName().equals("Anytown") && person.getLastName().equals("Smith"));
Annotations
@Override
tapback to summary
public FixedSizeMap<K, V> tap(Procedure<? super V> procedure)

Overrides org.eclipse.collections.impl.map.mutable.AbstractMutableMap.tap.

Implements org.eclipse.collections.api.map.FixedSizeMap.tap, org.eclipse.collections.api.map.MutableMap.tap, org.eclipse.collections.api.map.MutableMapIterable.tap, org.eclipse.collections.api.map.MapIterable.tap, org.eclipse.collections.api.RichIterable.tap.

Doc from org.eclipse.collections.api.map.MapIterable.tap.

Executes the Procedure for each value of the map and returns this.

return peopleByCity.tap(person -> LOGGER.info(person.getName()));
Annotations
@Override
updateValueback to summary
public V updateValue(K key, Function0<? extends V> factory, Function<? super V, ? extends V> function)

Overrides org.eclipse.collections.impl.map.mutable.AbstractMutableMapIterable.updateValue.

Implements org.eclipse.collections.api.map.MutableMapIterable.updateValue.

Doc from org.eclipse.collections.api.map.MutableMapIterable.updateValue.

Looks up the value associated with key, applies the function to it, and replaces the value. If there is no value associated with key, starts it off with a value supplied by factory.

Annotations
@Override
updateValueWithback to summary
public <P> V updateValueWith(K key, Function0<? extends V> factory, Function2<? super V, ? super P, ? extends V> function, P parameter)

Overrides org.eclipse.collections.impl.map.mutable.AbstractMutableMapIterable.updateValueWith.

Implements org.eclipse.collections.api.map.MutableMapIterable.updateValueWith.

Doc from org.eclipse.collections.api.map.MutableMapIterable.updateValueWith.

Same as updateValue(Object, Function0, Function) with a Function2 and specified parameter which is passed to the function.

Annotations
@Override
withAllKeyValueArgumentsback to summary
public MutableMap<K, V> withAllKeyValueArguments(Pair<? extends K, ? extends V>... keyValues)

Overrides org.eclipse.collections.impl.map.mutable.AbstractMutableMap.withAllKeyValueArguments.

Implements org.eclipse.collections.api.map.MutableMap.withAllKeyValueArguments, org.eclipse.collections.api.map.MutableMapIterable.withAllKeyValueArguments.

Doc from org.eclipse.collections.api.map.MutableMapIterable.withAllKeyValueArguments.

Convenience var-args version of withAllKeyValues

Annotations
@Override
withAllKeyValuesback to summary
public MutableMap<K, V> withAllKeyValues(Iterable<? extends Pair<? extends K, ? extends V>> keyValues)

Overrides org.eclipse.collections.impl.map.mutable.AbstractMutableMap.withAllKeyValues.

Implements org.eclipse.collections.api.map.MutableMap.withAllKeyValues, org.eclipse.collections.api.map.MutableMapIterable.withAllKeyValues.

Doc from org.eclipse.collections.api.map.MutableMapIterable.withAllKeyValues.

This method allows mutable, fixed size, and immutable maps the ability to add elements to their existing elements. In order to support fixed size maps, a new instance of a map would have to be returned including the keys and values of the original plus all the additional keys and values. In the case of mutable maps, the original map is modified and then returned. In order to use this method properly with mutable and fixed size maps the following approach must be taken:

map = map.withAllKeyValues(FastList.newListWith(PairImpl.of("new key", "new value")));
In the case of FixedSizeMap, a new instance will be returned by withAllKeyValues, and any variables that previously referenced the original map will need to be redirected to reference the new instance. In the case of a FastMap or UnifiedMap, you will be replacing the reference to map with map, since FastMap and UnifiedMap will both return "this" after calling put on themselves.
Annotations
@Override
withoutAllKeysback to summary
public MutableMap<K, V> withoutAllKeys(Iterable<? extends K> keys)

Overrides org.eclipse.collections.impl.map.mutable.AbstractMutableMap.withoutAllKeys.

Implements org.eclipse.collections.api.map.MutableMap.withoutAllKeys, org.eclipse.collections.api.map.MutableMapIterable.withoutAllKeys.

Doc from org.eclipse.collections.api.map.MutableMapIterable.withoutAllKeys.

This method allows mutable, fixed size, and immutable maps the ability to remove elements from their existing elements. In order to support fixed size maps, a new instance of a map would have to be returned including the keys and values of the original minus all the keys and values to be removed. In the case of mutable maps, the original map is modified and then returned. In order to use this method properly with mutable and fixed size maps the following approach must be taken:

map = map.withoutAllKeys(FastList.newListWith("key1", "key2"));
In the case of FixedSizeMap, a new instance will be returned by withoutAllKeys, and any variables that previously referenced the original map will need to be redirected to reference the new instance. In the case of a FastMap or UnifiedMap, you will be replacing the reference to map with map, since FastMap and UnifiedMap will both return "this" after calling remove on themselves.
Annotations
@Override