X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Fedu%2Fberkeley%2Fsbp%2Futil%2FIntPairMap.java;h=5e9fe10e6d3e79c3467fee6e78f19aa71f0763f5;hb=476b0f25eb4554febad2bbed314bb48a888400c5;hp=c355488ec01826f06eacd1409ff2837f03767492;hpb=21b1b10a3ffb4b2021ad940f9cd722e3ed5300c4;p=sbp.git diff --git a/src/edu/berkeley/sbp/util/IntPairMap.java b/src/edu/berkeley/sbp/util/IntPairMap.java index c355488..5e9fe10 100644 --- a/src/edu/berkeley/sbp/util/IntPairMap.java +++ b/src/edu/berkeley/sbp/util/IntPairMap.java @@ -1,8 +1,11 @@ +// Copyright 2006-2007 all rights reserved; see LICENSE file for BSD-style license + package edu.berkeley.sbp.util; import java.util.*; -/** a mapping from keys of type K to sets of values of type T */ -public final class IntPairMap { +// 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 implements Iterable { private final HashMap hm = new HashMap(); @@ -12,7 +15,9 @@ public final class IntPairMap { 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 values() { return hm.values(); } public int size() { return hm.size(); } public void toArray(V[] v) { hm.values().toArray(v); } + public Iterator iterator() { return hm.values().iterator(); } }