add a second parameter argument to Invokable (two params now)
authoradam <adam@megacz.com>
Sun, 9 Sep 2007 19:03:00 +0000 (15:03 -0400)
committeradam <adam@megacz.com>
Sun, 9 Sep 2007 19:03:00 +0000 (15:03 -0400)
darcs-hash:20070909190300-5007d-f98570adb4512b0f7cf60d678e7001f6dcfdfecc.gz

src/edu/berkeley/sbp/util/FastSet.java
src/edu/berkeley/sbp/util/Invokable.java
src/edu/berkeley/sbp/util/TopologicalBag.java
src/edu/berkeley/sbp/util/Visitable.java
src/edu/berkeley/sbp/util/VisitableMap.java

index c8302b5..4e289cd 100644 (file)
@@ -43,10 +43,10 @@ public /*final*/ class FastSet<T> implements Iterator<T>, Iterable<T>, Visitable
         if (found) size--;
     }
 
-    public <B> void visit(Invokable<T,B> ivbc, B b) {
-        if (only!=null) ivbc.invoke(only, b);
+    public <B,C> void visit(Invokable<T,B,C> ivbc, B b, C c) {
+        if (only!=null) ivbc.invoke(only, b, c);
         else for(int j=0; j<size; j++)
-            ivbc.invoke((T)array[j], b);
+                 ivbc.invoke((T)array[j], b, c);
     }
 
     public int size() { return only==null ? size : 1; }
index 5a7320f..a295f96 100644 (file)
@@ -8,6 +8,6 @@ import java.util.*;
 import java.lang.reflect.*;
 import java.lang.ref.*;
 
-public interface Invokable<A,B> {
-    public void invoke(A a, B b);
+public interface Invokable<A,B,C> {
+    public void invoke(A a, B b, C c);
 }
index b034baf..28166fb 100644 (file)
@@ -103,11 +103,11 @@ public class TopologicalBag<K,V> implements MapBag<Topology<K>,V>, VisitableMap<
     private HashMap<K,Iterable<V>> cache = new HashMap<K,Iterable<V>>();
     public Iterable<V> getAll(Topology<K> k) { return h.get(k); }
 
-    public <B> void invoke(K k, Invokable<V,B> ivbc, B b) {
+    public <B,C> void invoke(K k, Invokable<V,B,C> ivbc, B b, C c) {
         for(Topology<K> t : h.keySet())
             if (t.contains(k))
                 for(V v : h.get(t))
-                    ivbc.invoke(v, b);
+                    ivbc.invoke(v, b, c);
     }
 
     public Iterable<V> get(K k) {
@@ -165,13 +165,13 @@ public class TopologicalBag<K,V> implements MapBag<Topology<K>,V>, VisitableMap<
                         return true;
                 return false;
             }
-            public <B> void invoke(K k, Invokable<V,B> ivbc, B b) {
+            public <B,C> void invoke(K k, Invokable<V,B,C> ivbc, B b, C c) {
                 int asint = f.invoke(k);
                 for(int i=0; i<size; i++) {
                     if (min[i] <= asint && max[i] >= asint) {
                         Object[] arr = v[i];
                         for(int j=0; j<arr.length; j++)
-                            ivbc.invoke((V)arr[j], b);
+                            ivbc.invoke((V)arr[j], b, c);
                     }
                 }
             }
index aa2f644..b795c57 100644 (file)
@@ -5,6 +5,6 @@ import java.util.*;
 
 public interface Visitable<V> {
 
-    public <B> void visit(Invokable<V,B> ivbc, B b);
+    public <B,C> void visit(Invokable<V,B,C> ivbc, B b, C c);
 
 }
index c57b7c8..c5f1a56 100644 (file)
@@ -8,7 +8,7 @@ import java.io.*;
 public interface VisitableMap<K,V> extends Serializable {
 
     /** invokes <tt>ivbc</tt> on each element of this map, passing constant arguments <tt>b</tt> and <tt>c</tt> */
-    public <B> void invoke(K k, Invokable<V,B> ivbc, B b);
+    public <B,C> void invoke(K k, Invokable<V,B,C> ivbc, B b, C c);
 
     /** returns true iff this map contains some value <tt>v</tt> for key <tt>k</tt> */
     public boolean contains(K k);