package com.android.camera.util; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; public class MultiMap { Map> map = new HashMap>(); public void put(K key, V value) { List l = map.get(key); if(l == null) { l = new ArrayList(); map.put(key, l); } l.add(value); } public List get(K key) { List l = map.get(key); if(l == null) { return Collections.emptyList(); } else return l; } public List remove(K key) { List l = map.remove(key); if(l == null) { return Collections.emptyList(); } else return l; } public Set keySet() { return map.keySet(); } public int size() { int total = 0; for(List l : map.values()) { total += l.size(); } return total; } public boolean isEmpty() { return map.isEmpty(); } }