Class ListingHash<K,V>

java.lang.Object
com.kingsrook.qqq.backend.core.utils.ListingHash<K,V>
All Implemented Interfaces:
Serializable, Map<K,List<V>>

public class ListingHash<K,V> extends Object implements Map<K,List<V>>, Serializable
Hash that provides "listing" capability -- keys map to lists of values that are automatically/easily added to
See Also:
  • Field Details

  • Constructor Details

    • ListingHash

      public ListingHash()
      Default constructor
    • ListingHash

      public ListingHash(Map<K,List<V>> sourceMap)
      Constructor where you can supply a source map (e.g., if you want a specific Map type (like LinkedHashMap), or with pre-values
  • Method Details

    • add

      public List<V> add(K key, V value)
      Add a value to the entry/list for this key
    • addAll

      public void addAll(Collection<V> vs, Function<V,K> keyFunction)
      Add all elements of the collection of v's to this listing hash, using keys generated by passing each v to the supplied keyFunction (which return's K's)
    • addAll

      public List<V> addAll(K key, Collection<V> values)
      Add multiple values to the entry/list for this key
    • addAll

      public void addAll(ListingHash<K,V> that)
      Add all object from another ListingHash ('that') to this one. Note, does it at the level of the whole key=list (e.g., if a key was already in this, it'll be replaced with the list from 'that'.
    • clear

      public void clear()
      Specified by:
      clear in interface Map<K,V>
    • containsKey

      public boolean containsKey(Object key)
      Specified by:
      containsKey in interface Map<K,V>
    • containsValue

      public boolean containsValue(Object value)
      Specified by:
      containsValue in interface Map<K,V>
    • entrySet

      public Set<Map.Entry<K,List<V>>> entrySet()
      Specified by:
      entrySet in interface Map<K,V>
    • equals

      public boolean equals(Object o)
      Specified by:
      equals in interface Map<K,V>
      Overrides:
      equals in class Object
    • get

      public List<V> get(Object key)
      Specified by:
      get in interface Map<K,V>
    • hashCode

      public int hashCode()
      Specified by:
      hashCode in interface Map<K,V>
      Overrides:
      hashCode in class Object
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface Map<K,V>
    • keySet

      public Set<K> keySet()
      Specified by:
      keySet in interface Map<K,V>
    • put

      public List<V> put(K key, List<V> value)
      Specified by:
      put in interface Map<K,V>
    • putAll

      public void putAll(Map<? extends K,? extends List<V>> t)
      Specified by:
      putAll in interface Map<K,V>
    • remove

      public List<V> remove(Object key)
      Specified by:
      remove in interface Map<K,V>
    • size

      public int size()
      Specified by:
      size in interface Map<K,V>
    • values

      public Collection<List<V>> values()
      Specified by:
      values in interface Map<K,V>