public class ReachabilitySet {
- public HashSet<TokenTupleSet> possibleReachabilities;
+ private HashSet<TokenTupleSet> possibleReachabilities;
public ReachabilitySet() {
possibleReachabilities = new HashSet<TokenTupleSet>();
}
+ public ReachabilitySet( TokenTupleSet tts ) {
+ possibleReachabilities = new HashSet<TokenTupleSet>();
+ possibleReachabilities.add( tts );
+ }
+
public ReachabilitySet( ReachabilitySet rs ) {
possibleReachabilities = (HashSet<TokenTupleSet>) rs.possibleReachabilities.clone(); // again, DEEP COPY?!
}
while( itrRelement.hasNext() ) {
TokenTuple e = (TokenTuple) itrRelement.next();
- if( o.contains( e ) ) {
- theUnion.union( new TokenTupleSet( e.increaseArity() ) );
+ if( o.containsToken( e.getToken() ) ) {
+ theUnion = theUnion.union( new TokenTupleSet( e.increaseArity() ) );
+ } else {
+ theUnion = theUnion.union( new TokenTupleSet( e ) );
}
}
+
+ Iterator itrOelement = o.iterator();
+ while( itrOelement.hasNext() ) {
+ TokenTuple e = (TokenTuple) itrOelement.next();
+
+ if( !theUnion.containsToken( e.getToken() ) ) {
+ theUnion = theUnion.union( new TokenTupleSet( e ) );
+ }
+ }
+
+ if( !theUnion.isEmpty() ) {
+ ctsOut = ctsOut.union(
+ new ChangeTupleSet(
+ new ChangeTuple( o, theUnion )
+ )
+ );
+ }
}
}
return ctsOut;
}
-}
-
-/*
-Set specialUnion( Set O, Set R ) {
- Set C = {}
-
- foreach o in O {
- foreach r in R {
-
- Set theUnion = {}
- foreach e in r {
- if o.contains( e ) {
- if e.isSummaryToken() { // wait, stronger condition?
- theUnion.add( e.copy().increaseArity() )
- } else {
- theUnion.add( e.copy() )
- }
- }
- }
+ public String toString() {
+ String s = "[";
- foreach e in o {
- if !theUnion.contains( e ) {
- theUnion.add( e.copy() )
- }
- }
+ Iterator i = this.iterator();
+ while( i.hasNext() ) {
+ s += "\n "+i.next();
+ }
- if !theUnion.isEmpty() {
- C.add( <o, theUnion> )
- }
+ s += "\n]";
+ return s;
}
- }
-
- return C
}
-*/