Class AbstractImmutableMultimap<K,V,C extends ImmutableCollection<V>>
- java.lang.Object
-
- org.eclipse.collections.impl.multimap.AbstractMultimap<K,V,C>
-
- org.eclipse.collections.impl.multimap.AbstractImmutableMultimap<K,V,C>
-
- All Implemented Interfaces:
ImmutableMultimap<K,V>,Multimap<K,V>
- Direct Known Subclasses:
ImmutableBagMultimapImpl,ImmutableListMultimapImpl,ImmutableSetMultimapImpl,ImmutableSortedBagMultimapImpl,ImmutableSortedSetMultimapImpl
public abstract class AbstractImmutableMultimap<K,V,C extends ImmutableCollection<V>> extends AbstractMultimap<K,V,C> implements ImmutableMultimap<K,V>
-
-
Field Summary
Fields Modifier and Type Field Description protected ImmutableMap<K,C>map
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractImmutableMultimap(ImmutableMap<K,C> immutableMap)Creates a new multimap that uses the provided immutableMap.protectedAbstractImmutableMultimap(MutableMap<K,C> map)Creates a new multimap that clones the provided map into an ImmutableMap.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Cget(K key)Returns a view of all values associated with the given key.protected ImmutableMap<K,C>getMap()booleanisEmpty()Returnstrueif there are no entries.SetIterable<K>keySet()Returns an unmodifiableSetIterableof keys with O(1) complexity.protected java.lang.ObjectreadResolve()intsize()Returns the number of key-value entry pairs.intsizeDistinct()Returns the number of distinct keys.ImmutableMultimap<K,V>toImmutable()Returns an immutable copy of this Multimap if it is not already immutable.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.-
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.ImmutableMultimap
collectKeyMultiValues, collectKeysValues, collectValues, flip, newEmpty, newWith, newWithAll, newWithout, newWithoutAll, rejectKeysMultiValues, rejectKeysValues, selectKeysMultiValues, selectKeysValues
-
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, toMutable, valuesView
-
-
-
-
Field Detail
-
map
protected final ImmutableMap<K,C extends ImmutableCollection<V>> map
-
-
Constructor Detail
-
AbstractImmutableMultimap
protected AbstractImmutableMultimap(MutableMap<K,C> map)
Creates a new multimap that clones the provided map into an ImmutableMap.- Parameters:
map- place to store the mapping from each key to its corresponding values
-
AbstractImmutableMultimap
protected AbstractImmutableMultimap(ImmutableMap<K,C> immutableMap)
Creates a new multimap that uses the provided immutableMap.- Parameters:
immutableMap- place to store the mapping from each key to its corresponding values
-
-
Method Detail
-
getMap
protected ImmutableMap<K,C> getMap()
- Specified by:
getMapin classAbstractMultimap<K,V,C extends ImmutableCollection<V>>
-
size
public int size()
Description copied from interface:MultimapReturns the number of key-value entry pairs.This method is implemented with O(1) (constant-time) performance.
-
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.
-
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.
-
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.
-
toImmutable
public ImmutableMultimap<K,V> toImmutable()
Description copied from interface:MultimapReturns an immutable copy of this Multimap if it is not already immutable. If the Multimap is immutable, it will return itself.The returned Multimap will be
Serializableif this Multimap isSerializable.- Specified by:
toImmutablein interfaceMultimap<K,V>
-
readResolve
protected java.lang.Object readResolve() throws java.io.ObjectStreamException- Throws:
java.io.ObjectStreamException
-
-