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 Details

  • Constructor Details

    • 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(Iterable<Pair<K,V>> inputIterable)
      Constructs a Multimap containing Iterable.
      Parameters:
      inputIterable - the mappings to initialize the multimap.
  • Method Details

    • createMap

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

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

      protected MutableMap<K,C> getMap()
      Specified by:
      getMap in class AbstractMultimap<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.
      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>
    • put

      public boolean put(K key, V value)
      Specified by:
      put in interface MutableMultimap<K,V>
    • remove

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

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

      private boolean putAllNotEmpty(K key, Iterable<? extends V> values)
    • putAll

      public <KK extends K, VV extends V> boolean putAll(Multimap<KK,VV> multimap)
      Specified by:
      putAll in interface MutableMultimap<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, Iterable<? extends V> values)
      Specified by:
      replaceValues in interface MutableMultimap<K,V>
    • removeAll

      public C removeAll(Object key)
      Specified by:
      removeAll in interface MutableMultimap<K,V>
    • clear

      public void clear()
      Specified by:
      clear in interface MutableMultimap<K,V>
    • keySet

      public SetIterable<K> keySet()
      Description copied from interface: Multimap
      Returns an unmodifiable SetIterable of keys with O(1) complexity.
      Specified by:
      keySet in interface Multimap<K,V>
    • 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, 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 MutableMap<K,RichIterable<V>> toMap()
      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>
    • toMap

      public <R extends 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(ObjectOutput out) throws IOException
      Throws:
      IOException
    • readExternal

      public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
      Throws:
      IOException
      ClassNotFoundException
    • readValuesFrom

      void readValuesFrom(ObjectInput in) throws IOException, ClassNotFoundException
      Throws:
      IOException
      ClassNotFoundException