From: adam Date: Sun, 27 May 2007 20:26:01 +0000 (-0400) Subject: add Serializable to util classes X-Git-Url: http://git.megacz.com/?p=sbp.git;a=commitdiff_plain;h=eeb3a8b49bdbf753b5a70734fbae7f2c1ac06702 add Serializable to util classes darcs-hash:20070527202601-5007d-3d09bfa657c0d97b5dca2800c9dc048543bcc6a6.gz --- diff --git a/src/edu/berkeley/sbp/Parser.java b/src/edu/berkeley/sbp/Parser.java index a3730b6..8af8005 100644 --- a/src/edu/berkeley/sbp/Parser.java +++ b/src/edu/berkeley/sbp/Parser.java @@ -106,7 +106,7 @@ public abstract class Parser { // Table ////////////////////////////////////////////////////////////////////////////// /** an SLR(1) parse table which may contain conflicts */ - class Table extends Grammar { + class Table extends Grammar implements Serializable { /** the start state */ final State start; @@ -118,13 +118,13 @@ public abstract class Parser { private int master_state_idx = 0; /** all the states for this table */ - HashSet> all_states = new HashSet>(); + private transient HashSet> all_states = new HashSet>(); /** all the doomed states in this table */ - HashMap,State> doomed_states = new HashMap,State>(); + private transient HashMap,State> doomed_states = new HashMap,State>(); /** all the non-doomed states in this table */ - HashMap,State> normal_states = new HashMap,State>(); + private transient HashMap,State> normal_states = new HashMap,State>(); Topology emptyTopology() { return Parser.this.emptyTopology(); } @@ -263,10 +263,10 @@ public abstract class Parser { * space+time complexity in otherwise simple grammars. There * is an example of this in the regression suite. */ - class State implements IntegerMappable, Iterable { + class State implements IntegerMappable, Serializable { public final int idx = master_state_idx++; - private final HashSet hs; + private final transient HashSet hs; public HashSet> conjunctStates = new HashSet>(); HashMap> gotoSetNonTerminals = new HashMap>(); diff --git a/src/edu/berkeley/sbp/util/EmptyIterator.java b/src/edu/berkeley/sbp/util/EmptyIterator.java index 2c099f3..bcb2aa5 100644 --- a/src/edu/berkeley/sbp/util/EmptyIterator.java +++ b/src/edu/berkeley/sbp/util/EmptyIterator.java @@ -2,8 +2,9 @@ package edu.berkeley.sbp.util; import java.util.*; +import java.io.*; -public final class EmptyIterator implements Iterable, Iterator { +public final class EmptyIterator implements Iterable, Iterator, Serializable { public void remove() { throw new Error(); } public boolean hasNext() { return false; } public T next() { throw new Error(); } diff --git a/src/edu/berkeley/sbp/util/IntegerTopology.java b/src/edu/berkeley/sbp/util/IntegerTopology.java index a84768e..316e59c 100644 --- a/src/edu/berkeley/sbp/util/IntegerTopology.java +++ b/src/edu/berkeley/sbp/util/IntegerTopology.java @@ -9,7 +9,7 @@ import edu.berkeley.sbp.*; import edu.berkeley.sbp.util.*; /** implementation of Topology for any class for which there is a mapping to the ints */ -public class IntegerTopology implements Topology { +public class IntegerTopology implements Topology, Serializable { private final Range.Set rs; private final Functor f; diff --git a/src/edu/berkeley/sbp/util/Range.java b/src/edu/berkeley/sbp/util/Range.java index 9dae4a3..b803480 100644 --- a/src/edu/berkeley/sbp/util/Range.java +++ b/src/edu/berkeley/sbp/util/Range.java @@ -35,12 +35,13 @@ 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 { + public static class Set implements Iterable, Serializable { public static final int DEFAULT_CAPACITY = 16; diff --git a/src/edu/berkeley/sbp/util/TopologicalBag.java b/src/edu/berkeley/sbp/util/TopologicalBag.java index eb71cdc..e3bd1b7 100644 --- a/src/edu/berkeley/sbp/util/TopologicalBag.java +++ b/src/edu/berkeley/sbp/util/TopologicalBag.java @@ -14,7 +14,7 @@ import java.lang.ref.*; // /** a mapping from topologies over K to sets of values of type V */ -public class TopologicalBag implements MapBag,V>, VisitableMap { +public class TopologicalBag implements MapBag,V>, VisitableMap, Serializable { // CRUCIAL INVARIANT: keys in this hashmap MUST be disjoint or the universe will implode private final HashMap,HashSet> h = new HashMap,HashSet>(); diff --git a/src/edu/berkeley/sbp/util/VisitableMap.java b/src/edu/berkeley/sbp/util/VisitableMap.java index 314f55e..944f891 100644 --- a/src/edu/berkeley/sbp/util/VisitableMap.java +++ b/src/edu/berkeley/sbp/util/VisitableMap.java @@ -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 { +public interface VisitableMap extends Serializable { /** invokes ivbc on each element of this map, passing constant arguments b and c */ public void invoke(K k, Invokable ivbc, B b);