Class MapSetMultiMap<K,V>

java.lang.Object
pascal.taie.util.collection.AbstractMultiMap<K,V>
pascal.taie.util.collection.MapSetMultiMap<K,V>
Type Parameters:
K - type of the keys in this map
V - type of the values in this map
All Implemented Interfaces:
Serializable, MultiMap<K,V>

public class MapSetMultiMap<K,V> extends AbstractMultiMap<K,V> implements Serializable
An implementation of MultiMap that stores key-value pairs as a map from key to the sets of its corresponding values.
See Also:
  • Constructor Details

  • Method Details

    • contains

      public boolean contains(K key, V value)
      Specified by:
      contains in interface MultiMap<K,V>
      Returns:
      true if this multimap contains at least one key-value pair with the key key and the value value.
    • containsKey

      public boolean containsKey(K key)
      Specified by:
      containsKey in interface MultiMap<K,V>
      Returns:
      true if this multimap contains at least one key-value pair with the key key.
    • get

      public Set<V> get(@Nonnull K key)
      Specified by:
      get in interface MultiMap<K,V>
      Returns:
      an unmodifiable view of the values associated with key in this multimap, if key is absent; otherwise, this returns an empty set.
    • put

      public boolean put(@Nonnull K key, @Nonnull V value)
      Description copied from interface: MultiMap
      Stores a key-value pair in this multimap.
      Specified by:
      put in interface MultiMap<K,V>
      Returns:
      true if the multimap changed.
    • putAll

      public boolean putAll(@Nonnull K key, @Nonnull Collection<? extends V> values)
      Description copied from interface: MultiMap
      Stores a key-value pair in this multimap for each of values, all using the same key, key.=
      Specified by:
      putAll in interface MultiMap<K,V>
    • putAll

      public boolean putAll(@Nonnull MultiMap<? extends K,? extends V> multiMap)
      Description copied from interface: MultiMap
      Stores all key-value pairs of multimap in this multimap.
      Specified by:
      putAll in interface MultiMap<K,V>
      Returns:
      true if the multimap changed
    • remove

      public boolean remove(K key, V value)
      Description copied from interface: MultiMap
      Removes a single key-value pair with the key key and the value value from this multimap, if such exists.
      Specified by:
      remove in interface MultiMap<K,V>
      Returns:
      true if the multimap changed
    • removeAll

      public boolean removeAll(K key)
      Description copied from interface: MultiMap
      Removes all values associated with the key key.

      Once this method returns, key will not be mapped to any values, so it will not appear in MultiMap.keySet().

      Specified by:
      removeAll in interface MultiMap<K,V>
      Returns:
      true if the multimap changed.
    • removeAll

      public boolean removeAll(K key, Collection<? extends V> values)
      Description copied from interface: MultiMap
      Removes all key-value pairs for key and values.
      Specified by:
      removeAll in interface MultiMap<K,V>
      Returns:
      true if the multimap changed.
    • keySet

      public Set<K> keySet()
      Specified by:
      keySet in interface MultiMap<K,V>
      Returns:
      an unmodifiable view of all distinct keys contained in this multimap. Note that the key set contains a key if and only if this multimap maps that key to at least one value.
    • entryIterator

      protected Iterator<Map.Entry<K,V>> entryIterator()
      Specified by:
      entryIterator in class AbstractMultiMap<K,V>
    • forEachSet

      public void forEachSet(@Nonnull BiConsumer<K,Set<V>> action)
      Description copied from interface: MultiMap
      Performs the given action for key-(value-set) pairs contained in this multimap.
      Specified by:
      forEachSet in interface MultiMap<K,V>
    • clear

      public void clear()
      Description copied from interface: MultiMap
      Removes all key-value pairs from the multimap, leaving it empty.
      Specified by:
      clear in interface MultiMap<K,V>
    • size

      public int size()
      Specified by:
      size in interface MultiMap<K,V>
      Returns:
      the number of key-value pairs in this multimap.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object