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
ConstructorsModifierConstructorDescriptionprotectedprotectedAbstractMutableMultimap(int size) protectedAbstractMutableMultimap(Iterable<Pair<K, V>> inputIterable) protectedAbstractMutableMultimap(MutableMap<K, C> newMap) protectedAbstractMutableMultimap(Pair<K, V>... pairs) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddToTotalSize(int value) This method is provided to allow for subclasses to provide the behavior.voidclear()protected voidThis 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 voidThis 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 Cprotected MutableMap<K, C> getMap()protected voidThis method is provided to allow for subclasses to provide the behavior.booleanisEmpty()Returnstrueif there are no entries.keySet()Returns an unmodifiableSetIterableof keys with O(1) complexity.booleanbooleanputAllAbstractMutableMultimap(AbstractMutableMultimap<KK, VV, MutableCollection<VV>> other) private booleanputAllNotEmpty(K key, Iterable<? extends V> values) putAllReadOnlyMultimap(Multimap<KK, VV> multimap) void(package private) voidbooleanreplaceValues(K key, Iterable<? extends V> values) intsize()Use the size method directly instead of totalSize internally so subclasses can override if necessary.intReturns the number of distinct keys.protected voidsubtractFromTotalSize(int value) This method is provided to allow for subclasses to provide the behavior.MutableMap<K, RichIterable<V>> toMap()Returns a newMutableMapof keys from this Multimap to the mapped values as aRichIterable.<R extends Collection<V>>
MutableMap<K, R> Returns a newMutableMapof keys from this Multimap to the mapped values as aRichIterable.voidMethods inherited from class 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, valuesViewMethods inherited from interface 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, valuesViewMethods inherited from interface 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
-
AbstractMutableMultimap
-
-
Method Details
-
createMap
-
createMapWithKeyCount
-
getMap
- Specified by:
getMapin classAbstractMultimap<K, V, C extends MutableCollection<V>>
-
size
-
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:MultimapReturns the number of distinct keys.- Specified by:
sizeDistinctin interfaceMultimap<K,V>
-
isEmpty
-
put
-
remove
-
putAll
-
putAllNotEmpty
-
putAll
-
putAllReadOnlyMultimap
-
putAllAbstractMutableMultimap
private <KK extends K, VV extends V> boolean putAllAbstractMutableMultimap(AbstractMutableMultimap<KK, VV, MutableCollection<VV>> other) -
replaceValues
- Specified by:
replaceValuesin interfaceMutableMultimap<K,V>
-
removeAll
-
clear
public void clear()- Specified by:
clearin interfaceMutableMultimap<K,V>
-
keySet
Description copied from interface:MultimapReturns an unmodifiableSetIterableof keys with O(1) complexity. -
get
Description copied from interface:MultimapReturns a view of all values associated with the given key.If the given key does not exist, an empty
RichIterableis returned. -
getIfAbsentPutAll
Description copied from interface:MutableMultimapPuts 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:
getIfAbsentPutAllin interfaceMutableMultimap<K,V>
-
getIfAbsentPutCollection
-
toMap
Description copied from interface:MultimapReturns a newMutableMapof keys from this Multimap to the mapped values as aRichIterable. -
toMap
Description copied from interface:MultimapReturns a newMutableMapof keys from this Multimap to the mapped values as aRichIterable. -
writeExternal
- Throws:
IOException
-
readExternal
- Throws:
IOExceptionClassNotFoundException
-
readValuesFrom
- Throws:
IOExceptionClassNotFoundException
-