Class AbstractMutableMultimap<K,​V,​C extends MutableCollection<V>>

    • Constructor Detail

      • AbstractMutableMultimap

        protected AbstractMutableMultimap()
      • AbstractMutableMultimap

        protected AbstractMutableMultimap​(MutableMap<K,​C> newMap)
      • AbstractMutableMultimap

        protected AbstractMutableMultimap​(int size)
      • AbstractMutableMultimap

        protected AbstractMutableMultimap​(Pair<K,​V>... pairs)
        Constructs a Multimap containing all the Pairs.
        Parameters:
        pairs - the mappings to initialize the multimap.
      • AbstractMutableMultimap

        protected AbstractMutableMultimap​(java.lang.Iterable<Pair<K,​V>> inputIterable)
        Constructs a Multimap containing Iterable.
        Parameters:
        inputIterable - the mappings to initialize the multimap.
    • Method Detail

      • createMap

        protected abstract MutableMap<K,​C> createMap()
      • createMapWithKeyCount

        protected abstract MutableMap<K,​C> createMapWithKeyCount​(int keyCount)
      • size

        public int size()
        Use the size method directly instead of totalSize internally so subclasses can override if necessary.
        Specified by:
        size in interface Multimap<K,​V>
      • 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 interface Multimap<K,​V>
      • isEmpty

        public boolean isEmpty()
        Description copied from interface: Multimap
        Returns true if there are no entries.
        Specified by:
        isEmpty in interface Multimap<K,​V>
      • remove

        public boolean remove​(java.lang.Object key,
                              java.lang.Object value)
        Specified by:
        remove in interface MutableMultimap<K,​V>
      • putAll

        public boolean putAll​(K key,
                              java.lang.Iterable<? extends V> values)
        Specified by:
        putAll in interface MutableMultimap<K,​V>
      • putAllNotEmpty

        private boolean putAllNotEmpty​(K key,
                                       java.lang.Iterable<? extends V> values)
      • putAllReadOnlyMultimap

        private <KK extends K,​VV extends V> boolean putAllReadOnlyMultimap​(Multimap<KK,​VV> multimap)
      • get

        public C get​(K key)
        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.

        Specified by:
        get in interface Multimap<K,​V>
        Specified by:
        get in interface MutableMultimap<K,​V>
        Parameters:
        key - the key to search for
      • getIfAbsentPutAll

        public C getIfAbsentPutAll​(K key,
                                   java.lang.Iterable<? extends V> values)
        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 of Multimap.get(Object)
        Specified by:
        getIfAbsentPutAll in interface MutableMultimap<K,​V>
      • getIfAbsentPutCollection

        private C getIfAbsentPutCollection​(K key)
      • toMap

        public <R extends java.util.Collection<V>> MutableMap<K,​R> toMap​(Function0<R> collectionFactory)
        Description copied from interface: Multimap
        Returns a new MutableMap of keys from this Multimap to the mapped values as a RichIterable.
        Specified by:
        toMap in interface Multimap<K,​V>
        Parameters:
        collectionFactory - used to create the collections that hold the values and affects the return type
      • 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.IOException
        java.lang.ClassNotFoundException
      • readValuesFrom

        void readValuesFrom​(java.io.ObjectInput in)
                     throws java.io.IOException,
                            java.lang.ClassNotFoundException
        Throws:
        java.io.IOException
        java.lang.ClassNotFoundException