add Serializable to util classes
authoradam <adam@megacz.com>
Sun, 27 May 2007 20:26:01 +0000 (16:26 -0400)
committeradam <adam@megacz.com>
Sun, 27 May 2007 20:26:01 +0000 (16:26 -0400)
darcs-hash:20070527202601-5007d-3d09bfa657c0d97b5dca2800c9dc048543bcc6a6.gz

src/edu/berkeley/sbp/Parser.java
src/edu/berkeley/sbp/util/EmptyIterator.java
src/edu/berkeley/sbp/util/IntegerTopology.java
src/edu/berkeley/sbp/util/Range.java
src/edu/berkeley/sbp/util/TopologicalBag.java
src/edu/berkeley/sbp/util/VisitableMap.java

index a3730b6..8af8005 100644 (file)
@@ -106,7 +106,7 @@ public abstract class Parser<Token, NodeType> {
     // Table //////////////////////////////////////////////////////////////////////////////
 
     /** an SLR(1) parse table which may contain conflicts */
-    class Table extends Grammar<Token> {
+    class Table extends Grammar<Token> implements Serializable {
 
         /** the start state */
         final State<Token>   start;
@@ -118,13 +118,13 @@ public abstract class Parser<Token, NodeType> {
         private int master_state_idx = 0;
 
         /** all the states for this table */
-        HashSet<State<Token>>                     all_states       = new HashSet<State<Token>>();
+        private transient HashSet<State<Token>>                     all_states       = new HashSet<State<Token>>();
 
         /** all the doomed states in this table */
-        HashMap<HashSet<Position>,State<Token>>   doomed_states    = new HashMap<HashSet<Position>,State<Token>>();
+        private transient HashMap<HashSet<Position>,State<Token>>   doomed_states    = new HashMap<HashSet<Position>,State<Token>>();
 
         /** all the non-doomed states in this table */
-        HashMap<HashSet<Position>,State<Token>>   normal_states    = new HashMap<HashSet<Position>,State<Token>>();
+        private transient HashMap<HashSet<Position>,State<Token>>   normal_states    = new HashMap<HashSet<Position>,State<Token>>();
 
         Topology<Token> emptyTopology() { return Parser.this.emptyTopology(); }
     
@@ -263,10 +263,10 @@ public abstract class Parser<Token, NodeType> {
          *  space+time complexity in otherwise simple grammars.  There
          *  is an example of this in the regression suite.
          */
-        class State<Token> implements IntegerMappable, Iterable<Position> {
+        class State<Token> implements IntegerMappable, Serializable {
         
             public  final     int               idx    = master_state_idx++;
-            private final     HashSet<Position> hs;
+            private final  transient   HashSet<Position> hs;
             public HashSet<State<Token>> conjunctStates = new HashSet<State<Token>>();
 
             HashMap<Sequence,State<Token>>      gotoSetNonTerminals = new HashMap<Sequence,State<Token>>();
index 2c099f3..bcb2aa5 100644 (file)
@@ -2,8 +2,9 @@
 
 package edu.berkeley.sbp.util;
 import java.util.*;
+import java.io.*;
 
-public final class EmptyIterator<T> implements Iterable<T>, Iterator<T> {
+public final class EmptyIterator<T> implements Iterable<T>, Iterator<T>, Serializable {
     public void        remove()   { throw new Error(); }
     public boolean     hasNext()  { return false; }
     public T           next()     { throw new Error(); }
index a84768e..316e59c 100644 (file)
@@ -9,7 +9,7 @@ import edu.berkeley.sbp.*;
 import edu.berkeley.sbp.util.*;
 
 /** implementation of <tt>Topology</tt> for any class for which there is a mapping to the <tt>int</tt>s */
-public class IntegerTopology<V> implements Topology<V> {
+public class IntegerTopology<V> implements Topology<V>, Serializable {
 
     private final Range.Set rs;
     private final Functor<V,Integer> f;
index 9dae4a3..b803480 100644 (file)
 package edu.berkeley.sbp.util;
 import java.util.*;
 import java.text.*;
+import java.io.*;
 
 /**
  * This class represents a range of integers (incuding positive and negative 
  * infinity).
  */
-public class Range {
+public class Range implements Serializable {
 
     private boolean negInf, posInf;
     private long min,max;
@@ -269,7 +270,7 @@ public class Range {
      *
      * @author Justin F. Chapweske
      */
-    public static class Set implements Iterable<Range> {
+    public static class Set implements Iterable<Range>, Serializable {
  
         public static final int DEFAULT_CAPACITY = 16;
     
index eb71cdc..e3bd1b7 100644 (file)
@@ -14,7 +14,7 @@ import java.lang.ref.*;
 //
 
 /** a mapping from topologies over <tt>K</tt> to <i>sets of</i> values of type <tt>V</tt> */
-public class TopologicalBag<K,V> implements MapBag<Topology<K>,V>, VisitableMap<K,V> {
+public class TopologicalBag<K,V> implements MapBag<Topology<K>,V>, VisitableMap<K,V>, Serializable {
 
     // CRUCIAL INVARIANT: keys in this hashmap MUST be disjoint or the universe will implode
     private final HashMap<Topology<K>,HashSet<V>> h = new HashMap<Topology<K>,HashSet<V>>();
index 314f55e..944f891 100644 (file)
@@ -2,9 +2,10 @@
 
 package edu.berkeley.sbp.util;
 import java.util.*;
+import java.io.*;
 
 /** a Map that knows how to apply an Invokable to all its elements */
-public interface VisitableMap<K,V> {
+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);