Module org.hsqldb

Class MultiValueHashMap<K,​V>

  • All Implemented Interfaces:
    Map<K,​V>

    public class MultiValueHashMap<K,​V>
    extends org.hsqldb.map.BaseHashMap
    implements Map<K,​V>
    A Map of Object keys to Object values which stores multiple values per key. The getValuesIterator(K key) method returns an iterator covering the values associated with the given key. The get(K key) method returns the first value (if any) associated with the key.

    This class does not store null keys.

    Since:
    1.9.0
    Author:
    Fred Toussi (fredt@users dot sourceforge.net)
    • Nested Class Summary

      • Nested classes/interfaces inherited from interface org.hsqldb.lib.Map

        Map.Entry<K,​V>
    • Field Summary

      • Fields inherited from class org.hsqldb.map.BaseHashMap

        ACCESS_MAX, emptyObjectArray
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean containsKey​(java.lang.Object key)  
      boolean containsValue​(java.lang.Object value)  
      Set<Map.Entry<K,​V>> entrySet()  
      V get​(java.lang.Object key)
      Returns one of the values associated with the given key.
      Iterator<V> getValuesIterator​(java.lang.Object key)
      Returns an iterator on all values associated with the key.
      Set<K> keySet()  
      <T> T[] keysToArray​(T[] array)  
      V put​(K key, V value)  
      void putAll​(Map<? extends K,​? extends V> m)  
      void putAll​(MultiValueHashMap<K,​V> m)  
      V remove​(java.lang.Object key)
      Removes all values associated with the key.
      boolean remove​(java.lang.Object key, java.lang.Object value)
      Removes the spacific value associated with the key.
      int valueCount​(java.lang.Object key)
      Counts the values associated with the key.
      Collection<V> values()  
      <T> T[] valuesToArray​(T[] array)  
      • Methods inherited from class org.hsqldb.map.BaseHashMap

        clear, clone, isEmpty, size
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • MultiValueHashMap

        public MultiValueHashMap()
      • MultiValueHashMap

        public MultiValueHashMap​(int initialCapacity)
                          throws java.lang.IllegalArgumentException
        Throws:
        java.lang.IllegalArgumentException
      • MultiValueHashMap

        public MultiValueHashMap​(int initialCapacity,
                                 ObjectComparator comparator)
                          throws java.lang.IllegalArgumentException
        Throws:
        java.lang.IllegalArgumentException
    • Method Detail

      • containsKey

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

        public boolean containsValue​(java.lang.Object value)
        Specified by:
        containsValue in interface Map<K,​V>
      • get

        public V get​(java.lang.Object key)
        Returns one of the values associated with the given key.
        Specified by:
        get in interface Map<K,​V>
        Parameters:
        key - the key
        Returns:
        any value associated with the key, or null if none
      • getValuesIterator

        public Iterator<V> getValuesIterator​(java.lang.Object key)
        Returns an iterator on all values associated with the key.
        Parameters:
        key - the key
        Returns:
        iterator on value associated with the key
      • put

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

        public V remove​(java.lang.Object key)
        Removes all values associated with the key.
        Specified by:
        remove in interface Map<K,​V>
        Parameters:
        key - the key
        Returns:
        any value associated with the key, or null if none
      • remove

        public boolean remove​(java.lang.Object key,
                              java.lang.Object value)
        Removes the spacific value associated with the key.
        Parameters:
        key - the key
        value - the value
        Returns:
        the value associated with the key, or null if none
      • valueCount

        public int valueCount​(java.lang.Object key)
        Counts the values associated with the key.
        Parameters:
        key - the key
        Returns:
        the count
      • putAll

        public void putAll​(Map<? extends K,​? extends V> m)
        Specified by:
        putAll in interface Map<K,​V>
      • keysToArray

        public <T> T[] keysToArray​(T[] array)
      • valuesToArray

        public <T> T[] valuesToArray​(T[] array)
      • keySet

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