From 1ef043e85670629b857984ada6d38172f3a230bf Mon Sep 17 00:00:00 2001 From: jjenista Date: Fri, 21 Oct 2011 21:16:00 +0000 Subject: [PATCH] some extras for multiviewmaps --- Robust/src/Util/JoinOpSetUnion.java | 16 ++++++++++++++++ Robust/src/Util/MultiViewMap.java | 20 ++++++++++++++++---- 2 files changed, 32 insertions(+), 4 deletions(-) create mode 100644 Robust/src/Util/JoinOpSetUnion.java diff --git a/Robust/src/Util/JoinOpSetUnion.java b/Robust/src/Util/JoinOpSetUnion.java new file mode 100644 index 00000000..452cbff3 --- /dev/null +++ b/Robust/src/Util/JoinOpSetUnion.java @@ -0,0 +1,16 @@ +package Util; + +import java.util.Set; + +public class JoinOpSetUnion implements JoinOp { + 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; + } +} diff --git a/Robust/src/Util/MultiViewMap.java b/Robust/src/Util/MultiViewMap.java index aad5f0bb..79e4eac2 100644 --- a/Robust/src/Util/MultiViewMap.java +++ b/Robust/src/Util/MultiViewMap.java @@ -32,6 +32,12 @@ public class MultiViewMap { private boolean checkTypes; private boolean checkConsistency; + + // for MultiViewMaps that don't need to use the value, + // template on type Object and map every key to this dummy + public static Object dummy = new Integer( -12345 ); + + // If the entire contents of this map are fullKey -> value: // -> 1 // -> 2 @@ -73,10 +79,6 @@ public class MultiViewMap { } - public int size() { - return fullKey2value.size(); - } - public boolean equals( Object o ) { if( this == o ) { return true; @@ -111,6 +113,16 @@ public class MultiViewMap { } + public int size() { + return fullKey2value.size(); + } + + + public void clear() { + fullKey2value.clear(); + view2partialKey2fullKeys.clear(); + } + public void put( MultiKey fullKey, T value ) { assert( typesMatch( fullKey ) ); -- 2.34.1