Class AbstractMutableMultimap<K,V,C extends MutableCollection<V>>
java.lang.Object
org.eclipse.collections.impl.multimap.AbstractMultimap<K,V,C>
org.eclipse.collections.impl.multimap.AbstractMutableMultimap<K,V,C>
- All Implemented Interfaces:
Multimap<K,
,V> MutableMultimap<K,
V>
- Direct Known Subclasses:
AbstractMutableBagMultimap
,AbstractMutableListMultimap
,AbstractMutableSetMultimap
,AbstractSynchronizedPutMultimap
,TreeBagMultimap
,TreeBagMultimap
,TreeBagMultimap
,TreeSortedSetMultimap
public abstract class AbstractMutableMultimap<K,V,C extends MutableCollection<V>>
extends AbstractMultimap<K,V,C>
implements MutableMultimap<K,V>
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
protected
AbstractMutableMultimap
(int size) protected
AbstractMutableMultimap
(Iterable<Pair<K, V>> inputIterable) protected
AbstractMutableMultimap
(MutableMap<K, C> newMap) protected
AbstractMutableMultimap
(Pair<K, V>... pairs) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
addToTotalSize
(int value) This method is provided to allow for subclasses to provide the behavior.void
clear()
protected void
This method is provided to allow for subclasses to provide the behavior.protected abstract MutableMap
<K, C> protected abstract MutableMap
<K, C> createMapWithKeyCount
(int keyCount) protected void
This method is provided to allow for subclasses to provide the behavior.Returns a view of all values associated with the given key.getIfAbsentPutAll
(K key, Iterable<? extends V> values) Puts values into multimap if there are no values already associated with key.private C
protected MutableMap
<K, C> getMap()
protected void
This method is provided to allow for subclasses to provide the behavior.boolean
isEmpty()
Returnstrue
if there are no entries.keySet()
Returns an unmodifiableSetIterable
of keys with O(1) complexity.boolean
boolean
putAllAbstractMutableMultimap
(AbstractMutableMultimap<KK, VV, MutableCollection<VV>> other) private boolean
putAllNotEmpty
(K key, Iterable<? extends V> values) putAllReadOnlyMultimap
(Multimap<KK, VV> multimap) void
(package private) void
boolean
replaceValues
(K key, Iterable<? extends V> values) int
size()
Use the size method directly instead of totalSize internally so subclasses can override if necessary.int
Returns the number of distinct keys.protected void
subtractFromTotalSize
(int value) This method is provided to allow for subclasses to provide the behavior.toMap()
Returns a newMutableMap
of keys from this Multimap to the mapped values as aRichIterable
.<R extends Collection<V>>
MutableMap<K, R> Returns a newMutableMap
of keys from this Multimap to the mapped values as aRichIterable
.void
Methods inherited from class org.eclipse.collections.impl.multimap.AbstractMultimap
collectKeyMultiValues, collectKeysValues, collectValues, containsKey, containsKeyAndValue, containsValue, createCollection, createCollectionBlock, equals, forEachKey, forEachKeyMultiValues, forEachKeyValue, forEachValue, hashCode, keyBag, keyMultiValuePairsView, keysView, keyValuePairsView, multiValuesView, notEmpty, rejectKeysMultiValues, rejectKeysValues, selectKeysMultiValues, selectKeysValues, toString, valuesView
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.eclipse.collections.api.multimap.Multimap
collectKeyMultiValues, collectKeysValues, collectValues, containsKey, containsKeyAndValue, containsValue, equals, forEachKey, forEachKeyMultiValues, forEachKeyValue, forEachValue, hashCode, keyBag, keyMultiValuePairsView, keysView, keyValuePairsView, multiValuesView, notEmpty, rejectKeysMultiValues, rejectKeysValues, selectKeysMultiValues, selectKeysValues, toImmutable, toMutable, valuesView
Methods inherited from interface org.eclipse.collections.api.multimap.MutableMultimap
add, asSynchronized, collectKeyMultiValues, collectKeysValues, collectValues, flip, newEmpty, putAllPairs, putAllPairs, rejectKeysMultiValues, rejectKeysValues, selectKeysMultiValues, selectKeysValues, withKeyMultiValues, withKeyValue
-
Field Details
-
map
-
totalSize
protected int totalSize
-
-
Constructor Details
-
AbstractMutableMultimap
protected AbstractMutableMultimap() -
AbstractMutableMultimap
-
AbstractMutableMultimap
protected AbstractMutableMultimap(int size) -
AbstractMutableMultimap
- Parameters:
pairs
- the mappings to initialize the multimap.
-
AbstractMutableMultimap
- Parameters:
inputIterable
- the mappings to initialize the multimap.
-
-
Method Details
-
createMap
-
createMapWithKeyCount
-
getMap
- Specified by:
getMap
in classAbstractMultimap<K,
V, C extends MutableCollection<V>>
-
size
public int size()Use the size method directly instead of totalSize internally so subclasses can override if necessary. -
incrementTotalSize
protected void incrementTotalSize()This method is provided to allow for subclasses to provide the behavior. It should add 1 to the value that is returned by calling size(). -
decrementTotalSize
protected void decrementTotalSize()This method is provided to allow for subclasses to provide the behavior. It should remove 1 from the value that is returned by calling size(). -
addToTotalSize
protected void addToTotalSize(int value) This method is provided to allow for subclasses to provide the behavior. It should add the specified amount to the value that is returned by calling size(). -
subtractFromTotalSize
protected void subtractFromTotalSize(int value) This method is provided to allow for subclasses to provide the behavior. It should subtract the specified amount from the value that is returned by calling size(). -
clearTotalSize
protected void clearTotalSize()This method is provided to allow for subclasses to provide the behavior. It should set the value returned by size() to 0. -
sizeDistinct
public int sizeDistinct()Description copied from interface:Multimap
Returns the number of distinct keys.- Specified by:
sizeDistinct
in interfaceMultimap<K,
V>
-
isEmpty
public boolean isEmpty()Description copied from interface:Multimap
Returnstrue
if there are no entries. -
put
- Specified by:
put
in interfaceMutableMultimap<K,
V>
-
remove
- Specified by:
remove
in interfaceMutableMultimap<K,
V>
-
putAll
- Specified by:
putAll
in interfaceMutableMultimap<K,
V>
-
putAllNotEmpty
-
putAll
- Specified by:
putAll
in interfaceMutableMultimap<K,
V>
-
putAllReadOnlyMultimap
-
putAllAbstractMutableMultimap
private <KK extends K,VV extends V> boolean putAllAbstractMutableMultimap(AbstractMutableMultimap<KK, VV, MutableCollection<VV>> other) -
replaceValues
- Specified by:
replaceValues
in interfaceMutableMultimap<K,
V>
-
removeAll
- Specified by:
removeAll
in interfaceMutableMultimap<K,
V>
-
clear
public void clear()- Specified by:
clear
in interfaceMutableMultimap<K,
V>
-
keySet
Description copied from interface:Multimap
Returns an unmodifiableSetIterable
of keys with O(1) complexity. -
get
Description copied from interface:Multimap
Returns a view of all values associated with the given key.If the given key does not exist, an empty
RichIterable
is returned. -
getIfAbsentPutAll
Description copied from interface:MutableMultimap
Puts values into multimap if there are no values already associated with key. Then returns a view of the values associated with key, like the result ofMultimap.get(Object)
- Specified by:
getIfAbsentPutAll
in interfaceMutableMultimap<K,
V>
-
getIfAbsentPutCollection
-
toMap
Description copied from interface:Multimap
Returns a newMutableMap
of keys from this Multimap to the mapped values as aRichIterable
. -
toMap
Description copied from interface:Multimap
Returns a newMutableMap
of keys from this Multimap to the mapped values as aRichIterable
. -
writeExternal
- Throws:
IOException
-
readExternal
- Throws:
IOException
ClassNotFoundException
-
readValuesFrom
- Throws:
IOException
ClassNotFoundException
-