I'm looking for a common data sctructure that has the capabilities of a Map<K, List<V>>
Currently what I do is something like
public class MapOfLists <K,V>{
private Map<K, List<V>> map = new HashMap<K, List<V>>();
public void addItem(K key, V value){
if(!map.containsKey(key)){
map.put(key, new ArrayList<V>());
}
List<V> list = map.get(key);
list.add(value);
}
...
}
Isn't there a more generic solution? Am I reinventing the wheel (or a less important artifact)