PermutationKeyMap

ArrayListの要素をソートすれば、CombinationKeyMapになるかも。


import java.util.*;

public class PermutationKeyMap {

private Map body = new HashMap();

public int size() {
return body.size();
}

public boolean isEmpty() {
return body.isEmpty();
}

public boolean containsKey(Object key1, Object key2) {
return body.containsKey(permutableKey(key1, key2));
}

public boolean containsValue(Object value) {
return body.containsValue(value);
}

public Object get(Object key1, Object key2) {
return body.get(permutableKey(key1, key2));
}

public Object put(Object key1, Object key2, Object value) {
return body.put(permutableKey(key1, key2), value);
}

public Object remove(Object key1, Object key2) {
return body.remove(permutableKey(key1, key2));
}

public void putAll(PermutableKeyMap t) {
body.putAll(t.body);
}

public void clear() {
body.clear();
}

public Set keySet() {
return body.keySet();
}

public Collection values() {
return body.values();
}

public Set entrySet() {
return body.entrySet();
}

public boolean equals(Object o) {
return (o instanceof PermutableKeyMap)
&& body.equals(((PermutableKeyMap) o).body);
}

public int hashCode() {
return body.hashCode();
}

private List permutableKey(Object key1, Object key2) {
List key = new ArrayList();
key.add(key1);
key.add(key2);
return key;
}

}