// a change touple is a pair that indicates if the
// first TokenTupleSet is found in a ReachabilitySet,
// then the second TokenTupleSet should be added
+
+// THIS CLASS IS IMMUTABLE!
+
public class ChangeTuple
{
private TokenTupleSet toMatch;
return toMatch.hashCode() + toAdd.hashCode();
}
- public ChangeTuple copy() {
- return new ChangeTuple( toMatch, toAdd );
- }
-
public String toString() {
return new String( "<"+toMatch+" -> "+toAdd+">" );
}
changeTuples = (HashSet<ChangeTuple>) cts.changeTuples.clone(); //COPY?!
}
+ public Iterator iterator() {
+ return changeTuples.iterator();
+ }
+
public ChangeTupleSet union( ChangeTupleSet ctsIn ) {
ChangeTupleSet ctsOut = new ChangeTupleSet( this );
ctsOut.changeTuples.addAll( ctsIn.changeTuples );
possibleReachabilities = (HashSet<TokenTupleSet>) rs.possibleReachabilities.clone(); // again, DEEP COPY?!
}
+ public Iterator iterator() {
+ return possibleReachabilities.iterator();
+ }
+
public ReachabilitySet union( ReachabilitySet rsIn ) {
ReachabilitySet rsOut = new ReachabilitySet( this );
rsOut.possibleReachabilities.addAll( rsIn.possibleReachabilities );
public ReachabilitySet intersection( ReachabilitySet rsIn ) {
ReachabilitySet rsOut = new ReachabilitySet();
- Iterator i = this.possibleReachabilities.iterator();
+ Iterator i = this.iterator();
while( i.hasNext() ) {
TokenTupleSet tts = (TokenTupleSet) i.next();
if( rsIn.possibleReachabilities.contains( tts ) ) {
return rsOut;
}
- /*
public ChangeTupleSet unionUpArity( ReachabilitySet rsIn ) {
-
+ ChangeTupleSet ctsOut = new ChangeTupleSet();
+
+ Iterator itrO = this.iterator();
+ while( itrO.hasNext() ) {
+ TokenTupleSet o = (TokenTupleSet) itrO.next();
+
+ Iterator itrR = rsIn.iterator();
+ while( itrR.hasNext() ) {
+ TokenTupleSet r = (TokenTupleSet) itrR.next();
+
+ TokenTupleSet theUnion = new TokenTupleSet();
+
+ Iterator itrRelement = r.iterator();
+ while( itrRelement.hasNext() ) {
+ TokenTuple e = (TokenTuple) itrRelement.next();
+
+ if( o.contains( e ) ) {
+ theUnion.union( new TokenTupleSet( e.increaseArity() ) );
+ }
+ }
+ }
+ }
+
+ 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() )
+ }
+ }
+ }
+
+ foreach e in o {
+ if !theUnion.contains( e ) {
+ theUnion.add( e.copy() )
+ }
+ }
+
+ if !theUnion.isEmpty() {
+ C.add( <o, theUnion> )
+ }
+
+ }
+ }
+
+ return C
+}
+*/
// a token touple is a pair that indicates a
// heap region node and an arity
+
+// THIS CLASS IS IMMUTABLE!
+
public class TokenTuple
{
private Integer token;
public Integer getToken() { return token; }
public int getArity() { return arity; }
- public void increaseArity() {
+ public TokenTuple increaseArity() {
if( isNewSummary ) {
- arity = ARITY_MANY;
+ return new TokenTuple( token, isNewSummary, ARITY_MANY );
}
+ return this;
}
public boolean equals( Object o ) {
return token.intValue();
}
- public TokenTuple copy() {
- return new TokenTuple( token,
- isNewSummary,
- arity );
- }
-
public String toString() {
String s = "";
if( isNewSummary ) {
tokenTuples = (HashSet<TokenTuple>) tts.tokenTuples.clone(); //COPY?!
}
+ public Iterator iterator() {
+ return tokenTuples.iterator();
+ }
+
public TokenTupleSet union( TokenTupleSet ttsIn ) {
TokenTupleSet ttsOut = new TokenTupleSet( this );
ttsOut.tokenTuples.addAll( ttsIn.tokenTuples );
- /*
- Iterator i = ttsIn.tokenTuples.iterator();
- while( i.hasNext() ) {
- ttsOut.tokenTuples.add( (TokenTuple) i.next() );
- }
- */
-
return ttsOut;
}
+ public boolean contains( TokenTuple tt ) {
+ return tokenTuples.contains( tt );
+ }
+
public String toString() {
return tokenTuples.toString();
}