optimizations to FastSet: make it final again, don't shift the contents of the entire...
[sbp.git] / src / edu / berkeley / sbp / util / IntPairMap.java
index db12004..5e9fe10 100644 (file)
@@ -1,9 +1,11 @@
+// Copyright 2006-2007 all rights reserved; see LICENSE file for BSD-style license
+
 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 <tt>int</tt>'s to <tt>V</tt>'s */
-public final class IntPairMap<V> {
+public final class IntPairMap<V> implements Iterable<V> {
 
     private final HashMap<Long, V> hm = new HashMap<Long, V>();
 
@@ -13,7 +15,9 @@ public final class IntPairMap<V> {
 
     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 void remove(IntegerMappable k1, IntegerMappable k2) { hm.remove(key(k1, k2)); }
     public Iterable<V> values() { return hm.values(); }
     public int size() { return hm.size(); }
     public void toArray(V[] v) { hm.values().toArray(v); }
+    public Iterator<V> iterator() { return hm.values().iterator(); }
 }