Interface SetMultimap<K,V>

Type Parameters:
K - the key type
V - the value type
All Superinterfaces:
Multimap<K,V>
All Known Implementing Classes:
HashSetMultimap

public interface SetMultimap<K,V> extends Multimap<K,V>
A multimap that keeps the values of each key in a set, without duplicates: adding an entry it already contains leaves it unchanged.
Since:
0.1.2
  • Method Details

    • get

      Set<V> get(K key)
      Returns a live view of the values of a key, empty if the key is absent. Adding to the view adds entries to this multimap, the key included if it was absent.
      Specified by:
      get in interface Multimap<K,V>
      Parameters:
      key - the key
      Returns:
      the values of key
    • entries

      Set<Map.Entry<K,V>> entries()
      Returns a live view of the entries, grouped by key. The entries do not support Map.Entry.setValue(V).
      Specified by:
      entries in interface Multimap<K,V>
      Returns:
      the entries of this multimap, which are distinct
    • asMap

      Map<K,Set<V>> asMap()
      Returns a live view of this multimap as a map from each key to its values. The map and its sets support removal, but not put nor adding values.
      Specified by:
      asMap in interface Multimap<K,V>
      Returns:
      this multimap as a map
    • removeAll

      Set<V> removeAll(@Nullable Object key)
      Removes all the values of a key.
      Specified by:
      removeAll in interface Multimap<K,V>
      Parameters:
      key - the key
      Returns:
      the values removed, in an unmodifiable set, empty if the key was absent
      Throws:
      UnsupportedOperationException - if this multimap is unmodifiable
    • replaceValues

      Set<V> replaceValues(K key, Iterable<? extends V> values)
      Replaces all the values of a key. Replacing them with no values removes the key.
      Specified by:
      replaceValues in interface Multimap<K,V>
      Parameters:
      key - the key
      values - the new values of key
      Returns:
      the values replaced, in an unmodifiable set, empty if the key was absent
      Throws:
      UnsupportedOperationException - if this multimap is unmodifiable