some extras for multiviewmaps
authorjjenista <jjenista>
Fri, 21 Oct 2011 21:16:00 +0000 (21:16 +0000)
committerjjenista <jjenista>
Fri, 21 Oct 2011 21:16:00 +0000 (21:16 +0000)
Robust/src/Util/JoinOpSetUnion.java [new file with mode: 0644]
Robust/src/Util/MultiViewMap.java

diff --git a/Robust/src/Util/JoinOpSetUnion.java b/Robust/src/Util/JoinOpSetUnion.java
new file mode 100644 (file)
index 0000000..452cbff
--- /dev/null
@@ -0,0 +1,16 @@
+package Util;
+
+import java.util.Set;
+
+public class JoinOpSetUnion implements JoinOp<Set> {
+  public Set join( Set a, Set b ) {
+    Set out = new HashSet();
+    if( a != null ) {
+      out.addAll( a );
+    }
+    if( b != null ) {
+      out.addAll( b );
+    }
+    return out;
+  }
+}
index aad5f0bbb7c5b8d5ff444319265a46343e1176a3..79e4eac24ebecd03a024ba125c38f7f75b4e8ea8 100644 (file)
@@ -32,6 +32,12 @@ public class MultiViewMap<T> {
   private boolean checkTypes;\r
   private boolean checkConsistency;\r
 \r
+\r
+  // for MultiViewMaps that don't need to use the value,\r
+  // template on type Object and map every key to this dummy\r
+  public static Object dummy = new Integer( -12345 );\r
+\r
+\r
   //  If the entire contents of this map are fullKey -> value:\r
   //    <a,b> -> 1\r
   //    <c,b> -> 2\r
@@ -73,10 +79,6 @@ public class MultiViewMap<T> {
   }\r
 \r
 \r
-  public int size() {\r
-    return fullKey2value.size();\r
-  }\r
-\r
   public boolean equals( Object o ) {\r
     if( this == o ) {\r
       return true;\r
@@ -111,6 +113,16 @@ public class MultiViewMap<T> {
   }\r
 \r
 \r
+  public int size() {\r
+    return fullKey2value.size();\r
+  }\r
+\r
+\r
+  public void clear() {\r
+    fullKey2value.clear();\r
+    view2partialKey2fullKeys.clear();\r
+  }\r
+\r
  \r
   public void put( MultiKey fullKey, T value ) {\r
     assert( typesMatch( fullKey ) );\r