- java.lang.Object
-
- org.hsqldb.map.BaseHashMap
-
- org.hsqldb.lib.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)
-
-
Constructor Summary
Constructors Constructor Description MultiValueHashMap()MultiValueHashMap(int initialCapacity)MultiValueHashMap(int initialCapacity, ObjectComparator<K> comparator)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancontainsKey(java.lang.Object key)booleancontainsValue(java.lang.Object value)Set<Map.Entry<K,V>>entrySet()Vget(K 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)Vput(K key, V value)voidputAll(Map<K,V> m)voidputAll(MultiValueHashMap<K,V> m)Vremove(java.lang.Object key)Removes all values associated with the key.booleanremove(K key, V value)Removes the spacific value associated with the key.intvalueCount(K key)Counts the values associated with the key.Collection<V>values()<T> T[]valuesToArray(T[] array)
-
-
-
Constructor Detail
-
MultiValueHashMap
public MultiValueHashMap()
-
MultiValueHashMap
public MultiValueHashMap(int initialCapacity) throws java.lang.IllegalArgumentException- Throws:
java.lang.IllegalArgumentException
-
MultiValueHashMap
public MultiValueHashMap(int initialCapacity, ObjectComparator<K> comparator) throws java.lang.IllegalArgumentException- Throws:
java.lang.IllegalArgumentException
-
-
Method Detail
-
containsKey
public boolean containsKey(java.lang.Object key)
- Specified by:
containsKeyin interfaceMap<K,V>
-
containsValue
public boolean containsValue(java.lang.Object value)
- Specified by:
containsValuein interfaceMap<K,V>
-
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
-
remove
public V remove(java.lang.Object key)
Removes all values associated with the key.
-
remove
public boolean remove(K key, V value)
Removes the spacific value associated with the key.- Parameters:
key- the keyvalue- the value- Returns:
- the value associated with the key, or null if none
-
valueCount
public int valueCount(K key)
Counts the values associated with the key.- Parameters:
key- the key- Returns:
- the count
-
putAll
public void putAll(MultiValueHashMap<K,V> m)
-
keysToArray
public <T> T[] keysToArray(T[] array)
-
valuesToArray
public <T> T[] valuesToArray(T[] array)
-
-