Webiyo

This page was generated using Webiyo. See its source code and unit tests.

org/webiyo/util/MultiMap.java

package org.webiyo.util;

import java.util.*;

public class MultiMap <K,V> {

    private final Map<K, List<V>> map;

    public MultiMap() {
        map = new LinkedHashMap<K, List<V>>();
    }

    public Set<K> keySet() {
        return map.keySet();
    }

    public List<V> get(K key) {
        return map.get(key);
    }

    public void put(K key, V value) {
        List<V> values = map.get(key);
        if (values == null) {
            values = new ArrayList<V>();
            map.put(key, values);
        }
        values.add(value);
    }

}
SourceForge