java.lang.Object
me.sbasalaev.collection.Multimap<K,V,Opt<V>>
me.sbasalaev.collection.Map<K,V>
me.sbasalaev.collection.MutableMap<K,V>
- All Implemented Interfaces:
Cloneable,MultimapMutator<K,V, Opt<V>>
Map that can be mutated.
-
Nested Class Summary
Nested classes/interfaces inherited from class me.sbasalaev.collection.Map
Map.Builder<K,V> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanAssociates thevaluewith thekeyin this map.static <K,V> MutableMap <K, V> Returns new mutable map that initially contains given values.createIfMissing(K key, Supplier<? extends V> supplier) Returns value associated with given key, adds it if no value was associated.createOrUpdate(K key, Supplier<? extends V> supplier, UnaryOperator<V> transformer) Creates or updates association with given key in this map.static <K,V> MutableMap <K, V> empty()Returns new mutable map that is initially empty.booleanremoveAllKeysMatching(Predicate<? super K> condition) Removes all elements matching given condition from the collection.Removes key and associated value from this map.booleanretainAllKeysMatching(Predicate<? super K> condition) Retains only entries with key matching given condition.Associates thevaluewith thekeyin this map.updateIfPresent(K key, UnaryOperator<V> transformer) Updates association with given key if it is already present in this map.Methods inherited from class me.sbasalaev.collection.Map
build, clone, collectionEntries, entries, equals, forEachEntry, fromJava, get, keys, keySize, mapValues, of, of, of, of, of, of, toJavaMethods inherited from class me.sbasalaev.collection.Multimap
containsEntry, containsEntry, containsKey, hashCode, isEmpty, nonEmpty, size, toString, valuesMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface me.sbasalaev.collection.MultimapMutator
add, clear, removeEntry
-
Constructor Details
-
MutableMap
public MutableMap()Constructor for subclasses.
-
-
Method Details
-
empty
Returns new mutable map that is initially empty. -
copyOf
Returns new mutable map that initially contains given values. -
set
Associates thevaluewith thekeyin this map.- Returns:
- value that was previously associated with the key or empty optional if there was none.
-
add
Associates thevaluewith thekeyin this map. -
createIfMissing
Returns value associated with given key, adds it if no value was associated. If a mapping already exists in this map, just returns the value. Otherwise, given supplier is used to retrieve a value, it is put in this map and then returned. -
createOrUpdate
Creates or updates association with given key in this map. If given key is not in this map, given supplier is used to retrieve a value, it is put in this map and returned. If the map contains given key, the associated value is transformed using supplied transformer, the new association is put in this map and then new value is returned. -
updateIfPresent
Updates association with given key if it is already present in this map.- Returns:
- the new value associated with the key, or none() if the key was not present in this map.
-
removeKey
Removes key and associated value from this map. -
removeAllKeysMatching
Removes all elements matching given condition from the collection. Returns true if the collection was modified. -
retainAllKeysMatching
Retains only entries with key matching given condition. Returns true if the map was modified.
-