package edu.berkeley.sbp.util;
import java.util.*;
// FEATURE: make this faster (plenty of ways: quadradic probing hash table is one)
/** a sparse mapping from pairs of int's to V's */
public final class IntPairMap {
private final HashMap hm = new HashMap();
private static long key(IntegerMappable k1, IntegerMappable k2) {
return (k1==null ? 0 : (((long)k1.toInt()) << 32)) | (k2==null ? 0 : k2.toInt());
}
public void put(IntegerMappable k1, IntegerMappable k2, V v) { hm.put(key(k1, k2), v); }
public V get(IntegerMappable k1, IntegerMappable k2) { return hm.get(key(k1, k2)); }
public Iterable values() { return hm.values(); }
public int size() { return hm.size(); }
public void toArray(V[] v) { hm.values().toArray(v); }
}