public ReachabilitySet() {
possibleReachabilities = new HashSet<TokenTupleSet>();
+ //TokenTupleSet ttsEmpty = new TokenTupleSet().makeCanonical();
+ //possibleReachabilities.add( ttsEmpty );
}
public ReachabilitySet( TokenTupleSet tts ) {
+ this();
assert tts != null;
- possibleReachabilities = new HashSet<TokenTupleSet>();
possibleReachabilities.add( tts );
}
public ReachabilitySet( TokenTuple tt ) {
- this( new TokenTupleSet( tt ) );
+ this( new TokenTupleSet( tt ).makeCanonical() );
+ }
+
+ public ReachabilitySet( HashSet<TokenTupleSet> possibleReachabilities ) {
+ this.possibleReachabilities = possibleReachabilities;
}
public ReachabilitySet( ReachabilitySet rs ) {
return possibleReachabilities.contains( tts );
}
+ public ReachabilitySet add( TokenTupleSet tts ) {
+ ReachabilitySet rsOut = new ReachabilitySet( tts );
+ return this.union( rsOut );
+ }
+
+ public ReachabilitySet increaseArity( Integer token ) {
+ assert token != null;
+
+ HashSet<TokenTupleSet> possibleReachabilitiesNew = new HashSet<TokenTupleSet>();
+
+ Iterator itr = iterator();
+ while( itr.hasNext() ) {
+ TokenTupleSet tts = (TokenTupleSet) itr.next();
+ possibleReachabilitiesNew.add( tts.increaseArity( token ) );
+ }
+
+ return new ReachabilitySet( possibleReachabilitiesNew ).makeCanonical();
+ }
+
public Iterator iterator() {
return possibleReachabilities.iterator();
}
return rsOut.makeCanonical();
}
+
+ /*
+ public ReachabilitySet unionUpArity( ReachabilitySet rsIn ) {
+ assert rsIn != null;
+
+ ReachabilitySet rsOut = new ReachabilitySet();
+ Iterator itrIn;
+ Iterator itrThis;
+
+ itrIn = rsIn.iterator();
+ while( itrIn.hasNext() ) {
+ TokenTupleSet ttsIn = (TokenTupleSet) itrIn.next();
+
+ boolean foundEqual = false;
+
+ itrThis = this.iterator();
+ while( itrThis.hasNext() ) {
+ TokenTupleSet ttsThis = (TokenTupleSet) itrThis.next();
+
+ if( ttsIn.equalWithoutArity( ttsThis ) ) {
+ rsOut.possibleReachabilities.add( ttsIn.unionUpArity( ttsThis ) );
+ foundEqual = true;
+ continue;
+ }
+ }
+
+ if( !foundEqual ) {
+ rsOut.possibleReachabilities.add( ttsIn );
+ }
+ }
+
+ itrThis = this.iterator();
+ while( itrThis.hasNext() ) {
+ TokenTupleSet ttsThis = (TokenTupleSet) itrThis.next();
+
+ boolean foundEqual = false;
+
+ itrIn = rsIn.iterator();
+ while( itrIn.hasNext() ) {
+ TokenTupleSet ttsIn = (TokenTupleSet) itrIn.next();
+
+ if( ttsThis.equalWithoutArity( ttsIn ) ) {
+ foundEqual = true;
+ continue;
+ }
+ }
+
+ if( !foundEqual ) {
+ rsOut.possibleReachabilities.add( ttsThis );
+ }
+ }
+
+ return rsOut.makeCanonical();
+ }
+ */
- public ChangeTupleSet unionUpArity( ReachabilitySet rsIn ) {
+ public ChangeTupleSet unionUpArityToChangeSet( ReachabilitySet rsIn ) {
assert rsIn != null;
ChangeTupleSet ctsOut = new ChangeTupleSet();
}
+ public ReachabilitySet ageTokens( AllocationSite as ) {
+ assert as != null;
+
+ ReachabilitySet rsOut = new ReachabilitySet();
+
+ Iterator itrS = this.iterator();
+ while( itrS.hasNext() ) {
+ TokenTupleSet tts = (TokenTupleSet) itrS.next();
+ rsOut.possibleReachabilities.add( tts.ageTokens( as ) );
+ }
+
+ return rsOut.makeCanonical();
+ }
+
+
+ public ReachabilitySet pruneBy( ReachabilitySet rsIn ) {
+ assert rsIn != null;
+
+ ReachabilitySet rsOut = new ReachabilitySet();
+
+ Iterator itrB = this.iterator();
+ while( itrB.hasNext() ) {
+ TokenTupleSet ttsB = (TokenTupleSet) itrB.next();
+
+ boolean subsetExists = false;
+
+ Iterator itrA = rsIn.iterator();
+ while( itrA.hasNext() && !subsetExists ) {
+ TokenTupleSet ttsA = (TokenTupleSet) itrA.next();
+
+ if( ttsA.isSubset( ttsB ) ) {
+ subsetExists = true;
+ rsOut.possibleReachabilities.add( ttsB );
+ }
+ }
+ }
+
+ return rsOut.makeCanonical();
+ }
+
+
public boolean equals( Object o ) {
if( !(o instanceof ReachabilitySet) ) {
return false;
Iterator i = this.iterator();
while( i.hasNext() ) {
- s += "\\n "+i.next();
+ s += i.next();
+ if( i.hasNext() ) {
+ s += "\\n";
+ }
}
s += "]";
-
return s;
}
Iterator i = this.iterator();
while( i.hasNext() ) {
- s += "\n "+i.next();
+ s += i.next();
+ if( i.hasNext() ) {
+ s += "\n";
+ }
}
- s += "\n]";
-
+ s += "]";
return s;
}
}