Class HashMultiMap<K,T>

java.lang.Object
java.util.AbstractMap<K,ArrayList<T>>
java.util.HashMap<K,ArrayList<T>>
com.yetnt.utils.collection.HashMultiMap<K,T>
Type Parameters:
K - the type of keys maintained by this multimap
T - the type stored in the list
All Implemented Interfaces:
Serializable, Cloneable, Map<K,ArrayList<T>>

public class HashMultiMap<K,T> extends HashMap<K,ArrayList<T>>
A HashMap who maps 1 key to multiple values.

This class provides methods like putValue(Object, Object) to add a single value to the collection of values associated with a key, and getValues(Object) to retrieve all values for a given key.

From Jaiva VSCode Extension

Author:
Lehlogonolo Poole
See Also:
  • Constructor Details

    • HashMultiMap

      public HashMultiMap()
  • Method Details

    • putValue

      public void putValue(K key, T value)
      Adds a value to the list of values associated with the specified key. If the key does not already exist in the map, a new list is created for it.
      Parameters:
      key - The key to which the value should be added.
      value - The value to add to the list associated with the key.
    • getValues

      public ArrayList<T> getValues(K key)
      Retrieves the list of values associated with the specified key.
      Parameters:
      key - The key whose associated values are to be returned.
      Returns:
      The list of values associated with the specified key, or null if the key does not exist in the map.
    • holdsSingletonLists

      public boolean holdsSingletonLists()
    • findFirstKeyWhere

      public K findFirstKeyWhere(Predicate<ArrayList<T>> test)