Interface Multimap<K,V>

Type Parameters:
K - the type of keys maintained by this map
V - the type of mapped values
All Known Subinterfaces:
SetMultimap<K,V>
All Known Implementing Classes:
HashSetMultimap

public interface Multimap<K,V>
A map in which more than one value may be associated with and returned for a given key
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Removes all entries from this multimap.
    get(Object key)
    Returns the values that are associated to the specified key.
    boolean
    Returns true if this multimap contains no entries.
    Returns a Set with all the keys contained in this map.
    boolean
    put(K key, V value)
    Associates the specified value with the specified key in this map.
    boolean
    putAll(K key, Collection<? extends V> values)
    Associates the specified values with the specified key in this map.
    boolean
    putAll(K key, V... values)
    Associates the specified values with the specified key in this map.
    boolean
    remove(K key, V value)
    Removes the specified value from the specified key.
  • Method Details

    • put

      boolean put(K key, V value)
      Associates the specified value with the specified key in this map.
      Parameters:
      key - key with which the specified value is to be associated
      value - value to be associated with the specified key
      Returns:
      true if the specified value could be associated with the specified key
      Throws:
      NullPointerException - if key is null
    • putAll

      boolean putAll(K key, Collection<? extends V> values)
      Associates the specified values with the specified key in this map.
      Parameters:
      key - key with which the specified value is to be associated
      values - values to be associated with the specified key
      Returns:
      true if the specified values have changed this multimap
      Throws:
      NullPointerException - if key is null
    • putAll

      boolean putAll(K key, V... values)
      Associates the specified values with the specified key in this map.
      Parameters:
      key - key with which the specified value is to be associated
      values - values to be associated with the specified key
      Returns:
      true if the specified values have changed this multimap
      Throws:
      NullPointerException - if key is null
    • remove

      boolean remove(K key, V value)
      Removes the specified value from the specified key. If no value left, the associated key will be removed from the map.
      Parameters:
      key - key with which the specified value is associated
      value - value expected to be associated with the specified key
      Returns:
      true if the specified value could be removed from the specified key
      Throws:
      NullPointerException - if key is null
    • get

      Collection<V> get(Object key)
      Returns the values that are associated to the specified key. Returns a empty Collection if currently no values are assosicated to the key.
      Parameters:
      key - the key whose associated values should be returned
      Returns:
      the values that are associated to the specified key. Returns a empty Collection if currently no values are assosicated to the key.
      Throws:
      NullPointerException - if key is null
    • keySet

      Set<K> keySet()
      Returns a Set with all the keys contained in this map.
      Returns:
      Set with all the keys contained in this map
    • isEmpty

      boolean isEmpty()
      Returns true if this multimap contains no entries.
      Returns:
      true if this multimap contains no entries
    • clear

      void clear()
      Removes all entries from this multimap.