Interface CollectionMap<K,V>

Type Parameters:
K - the type of keys in the map.
V - the type of values in the collections mapped to the keys.
All Superinterfaces:
Iterable<V>, Serializable
All Known Subinterfaces:
CollectionSortedMap<K,V>
All Known Implementing Classes:
AbstractCollectionConcurrentMap, AbstractCollectionHashtable, AbstractCollectionMap, AbstractCollectionSortedMap, ArrayListHashMap, ArrayListSortedMap, CopyOnWriteListConcurrentMap, EnumSetEnumMap, LinkedListHashMap, LinkedListSortedMap, SetHashMap, SetIdentityMap, SetSortedMap, SortedSetSortedMap, SynchronizedLinkedListConcurrentMap, VectorHashtable

public interface CollectionMap<K,V> extends Iterable<V>, Serializable
Interface for maps whose values are collections of a given component type.
Author:
Laurent Cohen
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addValues(K key, Collection<V> values)
    Add the specified values to the specified key.
    void
    addValues(K key, V... values)
    Add the specified values to the specified key.
    Get a collection of all the values for all keys.
    void
    Clear the map.
    boolean
    Determine whether this map contains the specified key.
    boolean
    containsValue(K key, V value)
    Determine whether the collection mapped to the specified key contains the specified value.
    boolean
    Determine whether at least one of the collections in the map contains the specified value.
    Get the set map entries.
    default void
    Default forEach implementation.
    getValues(K key)
    Get the collection of values maped to the specified key.
    boolean
    Determine whether this map is empty.
    iterator(Lock lock)
    Get an iterator which uses the specified lock.
    Get the set of keys in the map.
    void
    putValue(K key, V value)
    Add a value for the specified key.
    removeKey(K key)
    Remove the specified key from this map.
    boolean
    removeValue(K key, V value)
    Remove a value from the specified key.
    int
    removeValues(K key, V... values)
    Remove the specified values from the specified key.
    int
    Get the total number of elements in this collection map.

    Methods inherited from interface java.lang.Iterable

    forEach, iterator, spliterator
  • Method Details

    • putValue

      void putValue(K key, V value)
      Add a value for the specified key.
      Parameters:
      key - the key for which to add a value.
      value - the value to add.
    • removeValue

      boolean removeValue(K key, V value)
      Remove a value from the specified key.
      Parameters:
      key - the key from which to remove a value.
      value - the value to remove.
      Returns:
      true if an element was removed, false otherwise.
    • addValues

      void addValues(K key, Collection<V> values)
      Add the specified values to the specified key. This is a bulk operation.
      Parameters:
      key - the key to which to add the values.
      values - the values to add to the key.
    • addValues

      void addValues(K key, V... values)
      Add the specified values to the specified key. This is a bulk operation.
      Parameters:
      key - the key to which to add the values.
      values - the values to add to the key.
    • removeValues

      int removeValues(K key, V... values)
      Remove the specified values from the specified key. This is a bulk operation.
      Parameters:
      key - the key for which to rmeove the values.
      values - the values to remove.
      Returns:
      the number of values that were actually removed, possibly zero.
    • removeKey

      Collection<V> removeKey(K key)
      Remove the specified key from this map.
      Parameters:
      key - the key to remove.
      Returns:
      collection of values that were removed, possibly null.
    • getValues

      Collection<V> getValues(K key)
      Get the collection of values maped to the specified key.
      Parameters:
      key - the key to lookup.
      Returns:
      a collection of values that mapped to the key, or null if no mapping exists for the key.
    • size

      int size()
      Get the total number of elements in this collection map. Note that the cost of the size() operation will be in O(n).
      Returns:
      the number of elements as an int value.
    • isEmpty

      boolean isEmpty()
      Determine whether this map is empty.
      Returns:
      true if the map is empty, false otherwise.
    • containsKey

      boolean containsKey(K key)
      Determine whether this map contains the specified key.
      Parameters:
      key - the key to lookup.
      Returns:
      true if there is a mapping for the key, false otherwise.
    • containsValue

      boolean containsValue(K key, V value)
      Determine whether the collection mapped to the specified key contains the specified value.
      Parameters:
      key - the key whose mapped collection is looked up^.
      value - the value to look in the collection.
      Returns:
      true if the map contains the key and the corresponding collection contains the value, false otehrwise.
    • containsValue

      boolean containsValue(V value)
      Determine whether at least one of the collections in the map contains the specified value.
      Parameters:
      value - the value to look up in the entire map.
      Returns:
      true if the map contains the value, false otehrwise.
    • iterator

      Iterator<V> iterator(Lock lock)
      Get an iterator which uses the specified lock.
      Parameters:
      lock - the lock used to synchronize access to the map.
      Returns:
      an iterator on the values of the map.
    • keySet

      Set<K> keySet()
      Get the set of keys in the map.
      Returns:
      a Set of all keys.
    • entrySet

      Set<Map.Entry<K,Collection<V>>> entrySet()
      Get the set map entries.
      Returns:
      a Set of all map entries.
    • clear

      void clear()
      Clear the map.
    • allValues

      List<V> allValues()
      Get a collection of all the values for all keys.
      Returns:
      a collection of all values in this map.
    • forEach

      default void forEach(BiConsumer<K,Collection<V>> consumer)
      Default forEach implementation.
      Parameters:
      consumer - the BiConsumer function.