Class AbstractMemoryEfficientMutableMap<K,V>
java.lang.Object
org.eclipse.collections.impl.AbstractRichIterable<V>
org.eclipse.collections.impl.map.AbstractMapIterable<K,V>
org.eclipse.collections.impl.map.mutable.AbstractMutableMapIterable<K,V>
org.eclipse.collections.impl.map.mutable.AbstractMutableMap<K,V>
org.eclipse.collections.impl.map.fixed.AbstractMemoryEfficientMutableMap<K,V>
- All Implemented Interfaces:
Cloneable, Iterable<V>, Map<K,V>, InternalIterable<V>, FixedSizeMap<K, V>, MapIterable<K, V>, MutableMap<K, V>, MutableMapIterable<K, V>, UnsortedMapIterable<K, V>, RichIterable<V>
- Direct Known Subclasses:
DoubletonMap, EmptyMap, SingletonMap, TripletonMap
abstract class AbstractMemoryEfficientMutableMap<K,V>
extends AbstractMutableMap<K,V>
implements FixedSizeMap<K,V>
-
Nested Class Summary
Nested classes/interfaces inherited from class AbstractMutableMap
AbstractMutableMap.ValuesCollectionCommon<V> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()abstract <K2,V2> FixedSizeMap <K2, V2> For each key and value of the map the function is evaluated.<E> MutableMap<K, V> collectKeysAndValues(Iterable<E> iterable, Function<? super E, ? extends K> keyFunction, Function<? super E, ? extends V> valueFunction) Adds all the entries derived fromiterabletothis.abstract <R> FixedSizeMap<R, V> collectKeysUnique(Function2<? super K, ? super V, ? extends R> function) For each key and value of the map the function is evaluated.abstract <R> FixedSizeMap<K, R> collectValues(Function2<? super K, ? super V, ? extends R> function) For each key and value of the map the function is evaluated.MutableMap<K, V> newEmpty()Creates a new instance of the same type, using the default capacity and growth parameters.MutableMap<K, V> newEmpty(int capacity) Creates a new instance of the same type, using the given capacity and the default growth parameters.voidabstract FixedSizeMap<K, V> reject(Predicate2<? super K, ? super V> predicate) 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.booleanremoveAllKeys(Set<? extends K> keys) Remove entries from the map at the specifiedkeys.booleanremoveIf(Predicate2<? super K, ? super V> predicate) Remove an entry from the map if thepredicateevaluates to true.Remove an entry from the map at the specifiedkey.abstract FixedSizeMap<K, V> select(Predicate2<? super K, ? super V> predicate) 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.Executes the Procedure for each element in the iterable and returnsthis.Looks up the value associated withkey, applies thefunctionto it, and replaces the value.<P> VupdateValueWith(K key, Function0<? extends V> factory, Function2<? super V, ? super P, ? extends V> function, P parameter) Same asMutableMapIterable.updateValue(Object, Function0, Function)with a Function2 and specified parameter which is passed to the function.MutableMap<K, V> withAllKeyValueArguments(Pair<? extends K, ? extends V>... keyValues) Convenience var-args version of withAllKeyValuesMutableMap<K, V> withAllKeyValues(Iterable<? extends Pair<? extends K, ? extends V>> keyValues) This method allows mutable, fixed size, and immutable maps the ability to add elements to their existing elements.MutableMap<K, V> withoutAllKeys(Iterable<? extends K> keys) This method allows mutable, fixed size, and immutable maps the ability to remove elements from their existing elements.Methods inherited from class AbstractMutableMap
asSynchronized, asUnmodifiable, clone, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, flatCollect, flip, groupBy, groupByEach, groupByUniqueKey, partition, partitionWith, reject, rejectWith, replaceAll, select, selectInstancesOf, selectWith, toImmutable, withKeyValue, withoutKey, zip, zipWithIndexMethods inherited from class AbstractMutableMapIterable
aggregateBy, countBy, countByEach, countByWith, detect, detectOptional, flipUniqueValues, getIfAbsentPut, getIfAbsentPut, getIfAbsentPutWith, getIfAbsentPutWithKey, iterator, keysView, keyValuesView, reduceBy, sumByDouble, sumByFloat, sumByInt, sumByLong, valuesViewMethods inherited from class AbstractMapIterable
allSatisfy, allSatisfyWith, anySatisfy, anySatisfyWith, asLazy, chunk, contains, detect, detectIfNone, detectOptional, detectWith, detectWithIfNone, detectWithOptional, each, forEachKey, forEachValue, forEachWith, forEachWithIndex, getFirst, getIfAbsent, getIfAbsentValue, getIfAbsentWith, getLast, getOnly, getOrDefault, ifPresentApply, isAbsent, keyAndValueEquals, keyAndValueHashCode, noneSatisfy, noneSatisfyWith, toArray, toArrayMethods inherited from class AbstractRichIterable
appendString, appendString, collect, collectIf, collectWith, containsAll, containsAllArguments, containsAllIterable, count, countWith, flatCollect, forEach, groupBy, groupByEach, groupByUniqueKey, injectInto, injectInto, injectInto, injectInto, injectInto, into, isEmpty, max, max, maxBy, min, min, minBy, reject, rejectWith, select, selectWith, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, toBag, toBiMap, toList, toMap, toSet, toSortedBag, toSortedBag, toSortedBagBy, toSortedListBy, toSortedMap, toSortedMap, toSortedMapBy, toSortedSet, toSortedSet, toSortedSetBy, toString, zip, zipWithIndexMethods inherited from class Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface FixedSizeMap
putAllMapIterable, withMap, withMapIterableMethods inherited from interface InternalIterable
forEach, forEachWith, forEachWithIndexMethods inherited from interface Map
compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, putIfAbsent, remove, replace, replace, replaceAll, size, valuesMethods inherited from interface MapIterable
containsKey, containsValue, detect, detectOptional, equals, forEachKey, forEachKeyValue, forEachValue, get, getIfAbsent, getIfAbsentValue, getIfAbsentWith, hashCode, ifPresentApply, injectIntoKeyValue, keysView, keyValuesView, parallelStream, spliterator, stream, toString, valuesViewMethods inherited from interface MutableMap
aggregateBy, aggregateBy, aggregateInPlaceBy, asSynchronized, asUnmodifiable, clone, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, flatCollect, flatCollectWith, flip, flipUniqueValues, groupBy, groupByEach, groupByUniqueKey, partition, partitionWith, reduceBy, reject, rejectWith, select, selectInstancesOf, selectWith, withKeyValue, withoutKey, zip, zipWithIndexMethods inherited from interface MutableMapIterable
add, countBy, countByEach, countByWith, forEach, getIfAbsentPut, getIfAbsentPut, getIfAbsentPutWith, getIfAbsentPutWithKey, getOrDefault, putPair, sumByDouble, sumByFloat, sumByInt, sumByLong, toImmutableMethods inherited from interface RichIterable
aggregateBy, allSatisfy, allSatisfyWith, anySatisfy, anySatisfyWith, appendString, appendString, appendString, asLazy, chunk, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, contains, containsAll, containsAllArguments, containsAllIterable, containsAny, containsAnyIterable, containsBy, containsNone, containsNoneIterable, count, countBy, countByEach, countByWith, countWith, detect, detectIfNone, detectOptional, detectWith, detectWithIfNone, detectWithOptional, each, flatCollect, flatCollectBoolean, flatCollectByte, flatCollectChar, flatCollectDouble, flatCollectFloat, flatCollectInt, flatCollectLong, flatCollectShort, flatCollectWith, forEach, getAny, getFirst, getLast, getOnly, groupBy, groupByAndCollect, groupByEach, groupByUniqueKey, injectInto, injectInto, injectInto, injectInto, injectInto, injectIntoDouble, injectIntoFloat, injectIntoInt, injectIntoLong, into, isEmpty, makeString, makeString, makeString, makeString, max, max, maxBy, maxByOptional, maxOptional, maxOptional, min, min, minBy, minByOptional, minOptional, minOptional, noneSatisfy, noneSatisfyWith, notEmpty, reduce, reduceBy, reduceInPlace, reduceInPlace, reject, rejectWith, select, selectWith, size, summarizeDouble, summarizeFloat, summarizeInt, summarizeLong, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, toArray, toArray, toBag, toBiMap, toImmutableBag, toImmutableBiMap, toImmutableList, toImmutableMap, toImmutableSet, toImmutableSortedBag, toImmutableSortedBag, toImmutableSortedBagBy, toImmutableSortedList, toImmutableSortedList, toImmutableSortedListBy, toImmutableSortedSet, toImmutableSortedSet, toImmutableSortedSetBy, toList, toMap, toMap, toSet, toSortedBag, toSortedBag, toSortedBagBy, toSortedList, toSortedList, toSortedListBy, toSortedMap, toSortedMap, toSortedMapBy, toSortedSet, toSortedSet, toSortedSetBy, zip, zipWithIndexMethods inherited from interface UnsortedMapIterable
toImmutable
-
Constructor Details
-
AbstractMemoryEfficientMutableMap
AbstractMemoryEfficientMutableMap()
-
-
Method Details
-
put
-
remove
-
putAll
-
clear
-
removeKey
Description copied from interface:MutableMapIterableRemove an entry from the map at the specifiedkey.- Specified by:
removeKeyin interfaceFixedSizeMap<K,V> - Specified by:
removeKeyin interfaceMutableMapIterable<K,V> - Returns:
- The value removed from entry at key, or null if not found.
- See Also:
-
removeAllKeys
Description copied from interface:MutableMapIterableRemove entries from the map at the specifiedkeys.- Specified by:
removeAllKeysin interfaceFixedSizeMap<K,V> - Specified by:
removeAllKeysin interfaceMutableMapIterable<K,V> - Returns:
trueif this map changed as a result of the call
-
removeIf
Description copied from interface:MutableMapIterableRemove an entry from the map if thepredicateevaluates to true.- Specified by:
removeIfin interfaceFixedSizeMap<K,V> - Specified by:
removeIfin interfaceMutableMapIterable<K,V> - Returns:
- true if any entry is removed.
-
collectKeysAndValues
public <E> MutableMap<K,V> collectKeysAndValues(Iterable<E> iterable, Function<? super E, ? extends K> keyFunction, Function<? super E, ? extends V> valueFunction) Description copied from interface:MutableMapAdds all the entries derived fromiterabletothis. The key and value for each entry is determined by applying thekeyFunctionandvalueFunctionto each item incollection. Any entry inmapthat has the same key as an entry inthiswill have its value replaced by that inmap.- Specified by:
collectKeysAndValuesin interfaceMutableMap<K,V>
-
updateValue
public V updateValue(K key, Function0<? extends V> factory, Function<? super V, ? extends V> function) Description copied from interface:MutableMapIterableLooks up the value associated withkey, applies thefunctionto it, and replaces the value. If there is no value associated withkey, starts it off with a value supplied byfactory.- Specified by:
updateValuein interfaceMutableMapIterable<K,V> - Overrides:
updateValuein classAbstractMutableMapIterable<K,V>
-
updateValueWith
public <P> V updateValueWith(K key, Function0<? extends V> factory, Function2<? super V, ? super P, ? extends V> function, P parameter) Description copied from interface:MutableMapIterableSame asMutableMapIterable.updateValue(Object, Function0, Function)with a Function2 and specified parameter which is passed to the function.- Specified by:
updateValueWithin interfaceMutableMapIterable<K,V> - Overrides:
updateValueWithin classAbstractMutableMapIterable<K,V>
-
merge
-
newEmpty
Description copied from interface:MutableMapIterableCreates a new instance of the same type, using the default capacity and growth parameters.- Specified by:
newEmptyin interfaceMutableMap<K,V> - Specified by:
newEmptyin interfaceMutableMapIterable<K,V>
-
newEmpty
Description copied from class:AbstractMutableMapCreates a new instance of the same type, using the given capacity and the default growth parameters.- Specified by:
newEmptyin classAbstractMutableMap<K,V>
-
withAllKeyValues
public MutableMap<K,V> withAllKeyValues(Iterable<? extends Pair<? extends K, ? extends V>> keyValues) Description copied from interface:MutableMapIterableThis 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.- Specified by:
withAllKeyValuesin interfaceMutableMap<K,V> - Specified by:
withAllKeyValuesin interfaceMutableMapIterable<K,V> - Overrides:
withAllKeyValuesin classAbstractMutableMap<K,V> - See Also:
-
withAllKeyValueArguments
Description copied from interface:MutableMapIterableConvenience var-args version of withAllKeyValues- Specified by:
withAllKeyValueArgumentsin interfaceMutableMap<K,V> - Specified by:
withAllKeyValueArgumentsin interfaceMutableMapIterable<K,V> - Overrides:
withAllKeyValueArgumentsin classAbstractMutableMap<K,V> - See Also:
-
withoutAllKeys
Description copied from interface:MutableMapIterableThis 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.- Specified by:
withoutAllKeysin interfaceMutableMap<K,V> - Specified by:
withoutAllKeysin interfaceMutableMapIterable<K,V> - Overrides:
withoutAllKeysin classAbstractMutableMap<K,V> - See Also:
-
tap
Description copied from interface:RichIterableExecutes the Procedure for each element in the iterable and returnsthis.Example using a Java 8 lambda expression:
RichIterable<Person> tapped = people.tap(person -> LOGGER.info(person.getName()));- Specified by:
tapin interfaceFixedSizeMap<K,V> - Specified by:
tapin interfaceMapIterable<K,V> - Specified by:
tapin interfaceMutableMap<K,V> - Specified by:
tapin interfaceMutableMapIterable<K,V> - Specified by:
tapin interfaceRichIterable<K>- Specified by:
tapin interfaceUnsortedMapIterable<K,V> - Overrides:
tapin classAbstractMutableMap<K,V> - See Also:
-
select
Description copied from interface:MapIterableFor 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"));- Specified by:
selectin interfaceMapIterable<K,V> - Specified by:
selectin interfaceMutableMap<K,V> - Specified by:
selectin interfaceMutableMapIterable<K,V> - Specified by:
selectin interfaceUnsortedMapIterable<K,V> - Overrides:
selectin classAbstractMutableMap<K,V>
-
collectValues
public abstract <R> FixedSizeMap<K,R> collectValues(Function2<? super K, ? super V, ? extends R> function) Description copied from interface:MapIterableFor 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());- Specified by:
collectValuesin interfaceMapIterable<K,V> - Specified by:
collectValuesin interfaceMutableMap<K,V> - Specified by:
collectValuesin interfaceMutableMapIterable<K,V> - Specified by:
collectValuesin interfaceUnsortedMapIterable<K,V> - Overrides:
collectValuesin classAbstractMutableMap<K,V>
-
collectKeysUnique
public abstract <R> FixedSizeMap<R,V> collectKeysUnique(Function2<? super K, ? super V, ? extends R> function) Description copied from interface:MapIterableFor 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.- Specified by:
collectKeysUniquein interfaceMapIterable<K,V> - Specified by:
collectKeysUniquein interfaceMutableMap<K,V> - Specified by:
collectKeysUniquein interfaceMutableMapIterable<K,V> - Overrides:
collectKeysUniquein classAbstractMutableMap<K,V>
-
collect
public abstract <K2,V2> FixedSizeMap<K2,V2> collect(Function2<? super K, ? super V, Pair<K2, V2>> function) Description copied from interface:MapIterableFor 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()));- Specified by:
collectin interfaceMapIterable<K,V> - Specified by:
collectin interfaceMutableMap<K,V> - Specified by:
collectin interfaceMutableMapIterable<K,V> - Specified by:
collectin interfaceUnsortedMapIterable<K,V> - Overrides:
collectin classAbstractMutableMapIterable<K,V>
-
reject
Description copied from interface:MapIterableFor 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"));- Specified by:
rejectin interfaceMapIterable<K,V> - Specified by:
rejectin interfaceMutableMap<K,V> - Specified by:
rejectin interfaceMutableMapIterable<K,V> - Specified by:
rejectin interfaceUnsortedMapIterable<K,V> - Overrides:
rejectin classAbstractMutableMap<K,V>
-