com.googlecode.whatswrong.javautils
Class HashMultiMapArrayList<K,V>

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by java.util.HashMap<K,java.util.List<V>>
          extended by com.googlecode.whatswrong.javautils.HashMultiMapArrayList<K,V>
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.util.Map<K,java.util.List<V>>

public class HashMultiMapArrayList<K,V>
extends java.util.HashMap<K,java.util.List<V>>

A HashMultiMapArrayList is a mapping from keys to array lists of values.

Author:
Sebastian Riedel
See Also:
Serialized Form

Field Summary
protected  java.util.List<V> emptyList
          the empty list to be returned when there is key without values.
 
Constructor Summary
HashMultiMapArrayList()
           
 
Method Summary
 void add(K key, V value)
          Adds a value to the list of values of the given key.
 HashMultiMapArrayList<K,V> deepcopy()
          Creates a deep copy of this mapping.
 java.util.List<V> get(java.lang.Object o)
          Returns the list of values associated with the given key.
 
Methods inherited from class java.util.HashMap
clear, clone, containsKey, containsValue, entrySet, isEmpty, keySet, put, putAll, remove, size, values
 
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Field Detail

emptyList

protected java.util.List<V> emptyList
the empty list to be returned when there is key without values.

Constructor Detail

HashMultiMapArrayList

public HashMultiMapArrayList()
Method Detail

add

public void add(K key,
                V value)
Adds a value to the list of values of the given key.

Parameters:
key - the key value.
value - the value to add to the list of values of the given key.

deepcopy

public HashMultiMapArrayList<K,V> deepcopy()
Creates a deep copy of this mapping.

Returns:
A deep copy of this mapping.

get

public java.util.List<V> get(java.lang.Object o)
Returns the list of values associated with the given key.

Specified by:
get in interface java.util.Map<K,java.util.List<V>>
Overrides:
get in class java.util.HashMap<K,java.util.List<V>>
Parameters:
o - the key to get the values for.
Returns:
a list of values for the given keys or the empty list of no such value exist.


Copyright © 2009. All Rights Reserved.