(K key, V value)
| 12 | |
| 13 | public class MultiMap<K, V> extends LinkedHashMap<K, List<V>> { |
| 14 | public void map(K key, V value) { |
| 15 | List<V> elementsForKey = get(key); |
| 16 | if ( elementsForKey==null ) { |
| 17 | elementsForKey = new ArrayList<V>(); |
| 18 | super.put(key, elementsForKey); |
| 19 | } |
| 20 | elementsForKey.add(value); |
| 21 | } |
| 22 | |
| 23 | public List<Pair<K,V>> getPairs() { |
| 24 | List<Pair<K,V>> pairs = new ArrayList<Pair<K,V>>(); |