1 package edu.berkeley.sbp.util;
4 /** a mapping from keys of type <tt>K</tt> to <i>sets</i> of values of type <tt>T</tt> */
5 public final class IntPairMap<V> {
7 private final HashMap<Long, V> hm = new HashMap<Long, V>();
9 private static long key(IntegerMappable k1, IntegerMappable k2) {
10 return (k1==null ? 0 : (((long)k1.toInt()) << 32)) | (k2==null ? 0 : k2.toInt());
13 public void put(IntegerMappable k1, IntegerMappable k2, V v) { hm.put(key(k1, k2), v); }
14 public V get(IntegerMappable k1, IntegerMappable k2) { return hm.get(key(k1, k2)); }
15 public Iterable<V> values() { return hm.values(); }
16 public int size() { return hm.size(); }
17 public void toArray(V[] v) { hm.values().toArray(v); }