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 Modifier and Type Field Description protected MutableMap<K,C>mapprotected inttotalSize
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractMutableMultimap()protectedAbstractMutableMultimap(int size)protectedAbstractMutableMultimap(java.lang.Iterable<Pair<K,V>> inputIterable)Constructs aMultimapcontainingIterable.protectedAbstractMutableMultimap(MutableMap<K,C> newMap)protectedAbstractMutableMultimap(Pair<K,V>... pairs)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidaddToTotalSize(int value)This method is provided to allow for subclasses to provide the behavior.voidclear()protected voidclearTotalSize()This method is provided to allow for subclasses to provide the behavior.protected abstract MutableMap<K,C>createMap()protected abstract MutableMap<K,C>createMapWithKeyCount(int keyCount)protected voiddecrementTotalSize()This method is provided to allow for subclasses to provide the behavior.Cget(K key)Returns a view of all values associated with the given key.CgetIfAbsentPutAll(K key, java.lang.Iterable<? extends V> values)Puts values into multimap if there are no values already associated with key.private CgetIfAbsentPutCollection(K key)protected MutableMap<K,C>getMap()protected voidincrementTotalSize()This method is provided to allow for subclasses to provide the behavior.booleanisEmpty()Returnstrueif there are no entries.SetIterable<K>keySet()Returns an unmodifiableSetIterableof keys with O(1) complexity.booleanput(K key, V value)booleanputAll(K key, java.lang.Iterable<? extends V> values)<KK extends K,VV extends V>
booleanputAll(Multimap<KK,VV> multimap)private <KK extends K,VV extends V>
booleanputAllAbstractMutableMultimap(AbstractMutableMultimap<KK,VV,MutableCollection<VV>> other)private booleanputAllNotEmpty(K key, java.lang.Iterable<? extends V> values)private <KK extends K,VV extends V>
booleanputAllReadOnlyMultimap(Multimap<KK,VV> multimap)voidreadExternal(java.io.ObjectInput in)(package private) voidreadValuesFrom(java.io.ObjectInput in)booleanremove(java.lang.Object key, java.lang.Object value)CremoveAll(java.lang.Object key)CreplaceValues(K key, java.lang.Iterable<? extends V> values)intsize()Use the size method directly instead of totalSize internally so subclasses can override if necessary.intsizeDistinct()Returns 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 java.util.Collection<V>>
MutableMap<K,R>toMap(Function0<R> collectionFactory)Returns a newMutableMapof keys from this Multimap to the mapped values as aRichIterable.voidwriteExternal(java.io.ObjectOutput out)-
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 Detail
-
map
protected MutableMap<K,C extends MutableCollection<V>> map
-
totalSize
protected int totalSize
-
-
Constructor Detail
-
AbstractMutableMultimap
protected AbstractMutableMultimap()
-
AbstractMutableMultimap
protected AbstractMutableMultimap(MutableMap<K,C> newMap)
-
AbstractMutableMultimap
protected AbstractMutableMultimap(int size)
-
AbstractMutableMultimap
protected AbstractMutableMultimap(Pair<K,V>... pairs)
- Parameters:
pairs- the mappings to initialize the multimap.
-
-
Method Detail
-
createMap
protected abstract MutableMap<K,C> createMap()
-
createMapWithKeyCount
protected abstract MutableMap<K,C> createMapWithKeyCount(int keyCount)
-
getMap
protected MutableMap<K,C> getMap()
- Specified by:
getMapin 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:MultimapReturns the number of distinct keys.- Specified by:
sizeDistinctin interfaceMultimap<K,V>
-
isEmpty
public boolean isEmpty()
Description copied from interface:MultimapReturnstrueif there are no entries.
-
remove
public boolean remove(java.lang.Object key, java.lang.Object value)- Specified by:
removein interfaceMutableMultimap<K,V>
-
putAll
public boolean putAll(K key, java.lang.Iterable<? extends V> values)
- Specified by:
putAllin interfaceMutableMultimap<K,V>
-
putAll
public <KK extends K,VV extends V> boolean putAll(Multimap<KK,VV> multimap)
- Specified by:
putAllin interfaceMutableMultimap<K,V>
-
putAllReadOnlyMultimap
private <KK extends K,VV extends V> boolean putAllReadOnlyMultimap(Multimap<KK,VV> multimap)
-
putAllAbstractMutableMultimap
private <KK extends K,VV extends V> boolean putAllAbstractMutableMultimap(AbstractMutableMultimap<KK,VV,MutableCollection<VV>> other)
-
replaceValues
public C replaceValues(K key, java.lang.Iterable<? extends V> values)
- Specified by:
replaceValuesin interfaceMutableMultimap<K,V>
-
removeAll
public C removeAll(java.lang.Object key)
- Specified by:
removeAllin interfaceMutableMultimap<K,V>
-
clear
public void clear()
- Specified by:
clearin interfaceMutableMultimap<K,V>
-
keySet
public SetIterable<K> keySet()
Description copied from interface:MultimapReturns an unmodifiableSetIterableof keys with O(1) complexity.
-
get
public C get(K key)
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
public C getIfAbsentPutAll(K key, java.lang.Iterable<? extends V> values)
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>
-
toMap
public MutableMap<K,RichIterable<V>> toMap()
Description copied from interface:MultimapReturns a newMutableMapof keys from this Multimap to the mapped values as aRichIterable.
-
toMap
public <R extends java.util.Collection<V>> MutableMap<K,R> toMap(Function0<R> collectionFactory)
Description copied from interface:MultimapReturns a newMutableMapof keys from this Multimap to the mapped values as aRichIterable.
-
writeExternal
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException- Throws:
java.io.IOException
-
readExternal
public void readExternal(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundException- Throws:
java.io.IOExceptionjava.lang.ClassNotFoundException
-
readValuesFrom
void readValuesFrom(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundException- Throws:
java.io.IOExceptionjava.lang.ClassNotFoundException
-
-