Class HashSetMultimap<K,V>

java.lang.Object
org.drasyl.util.HashSetMultimap<K,V>
Type Parameters:
K - the type of keys maintained by this map
V - the type of mapped values
All Implemented Interfaces:
Multimap<K,V>, SetMultimap<K,V>

public class HashSetMultimap<K,V> extends Object implements SetMultimap<K,V>
Hash table based implementation of the SetMultimap interface.

This data structure is not thread-safe!

  • Constructor Summary

    Constructors
    Constructor
    Description
     
    HashSetMultimap(int initialMapCapacity, int initialSetCapacity)
     
  • 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.
    final 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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • HashSetMultimap

      public HashSetMultimap(int initialMapCapacity, int initialSetCapacity)
    • HashSetMultimap

      public HashSetMultimap()
  • Method Details

    • put

      public boolean put(K key, V value)
      Description copied from interface: Multimap
      Associates the specified value with the specified key in this map.
      Specified by:
      put in interface Multimap<K,V>
      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
    • putAll

      public boolean putAll(K key, Collection<? extends V> values)
      Description copied from interface: Multimap
      Associates the specified values with the specified key in this map.
      Specified by:
      putAll in interface Multimap<K,V>
      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
    • putAll

      @SafeVarargs public final boolean putAll(K key, V... values)
      Description copied from interface: Multimap
      Associates the specified values with the specified key in this map.
      Specified by:
      putAll in interface Multimap<K,V>
      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
    • remove

      public boolean remove(K key, V value)
      Description copied from interface: Multimap
      Removes the specified value from the specified key. If no value left, the associated key will be removed from the map.
      Specified by:
      remove in interface Multimap<K,V>
      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
    • get

      public Set<V> get(Object key)
      Description copied from interface: Multimap
      Returns the values that are associated to the specified key. Returns a empty Collection if currently no values are assosicated to the key.
      Specified by:
      get in interface Multimap<K,V>
      Specified by:
      get in interface SetMultimap<K,V>
      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.
    • keySet

      public Set<K> keySet()
      Description copied from interface: Multimap
      Returns a Set with all the keys contained in this map.
      Specified by:
      keySet in interface Multimap<K,V>
      Returns:
      Set with all the keys contained in this map
    • isEmpty

      public boolean isEmpty()
      Description copied from interface: Multimap
      Returns true if this multimap contains no entries.
      Specified by:
      isEmpty in interface Multimap<K,V>
      Returns:
      true if this multimap contains no entries
    • clear

      public void clear()
      Description copied from interface: Multimap
      Removes all entries from this multimap.
      Specified by:
      clear in interface Multimap<K,V>