return tokenTuples.iterator();
}
+ public TokenTupleSet add( TokenTuple tt ) {
+ TokenTupleSet ttsOut = new TokenTupleSet( tt );
+ return this.union( ttsOut );
+ }
+
public TokenTupleSet union( TokenTupleSet ttsIn ) {
TokenTupleSet ttsOut = new TokenTupleSet( this );
ttsOut.tokenTuples.addAll( ttsIn.tokenTuples );
return ttsOut.makeCanonical();
}
+ /*
+ public TokenTupleSet unionUpArity( TokenTupleSet ttsIn ) {
+ TokenTupleSet ttsOut = new TokenTupleSet();
+
+ Iterator itrIn = ttsIn.iterator();
+ while( itrIn.hasNext() ) {
+ TokenTuple ttIn = (TokenTuple) itrIn.next();
+
+ if( this.containsToken( ttIn.getToken() ) ) {
+ ttsOut.tokenTuples.add( ttIn.increaseArity() );
+ } else {
+ ttsOut.tokenTuples.add( ttIn );
+ }
+ }
+
+ Iterator itrThis = this.iterator();
+ while( itrThis.hasNext() ) {
+ TokenTuple ttThis = (TokenTuple) itrThis.next();
+
+ if( !ttsIn.containsToken( ttThis.getToken() ) ) {
+ ttsOut.tokenTuples.add( ttThis );
+ }
+ }
+
+ return ttsOut.makeCanonical();
+ }
+ */
+
public boolean isEmpty() {
return tokenTuples.isEmpty();
}
return tokenTuples.contains( tt );
}
+ // only needs to be done if newSummary is true? RIGHT?
+ public TokenTupleSet increaseArity( Integer token ) {
+ TokenTuple tt
+ = new TokenTuple( token, true, TokenTuple.ARITY_ONE ).makeCanonical();
+ if( tokenTuples.contains( tt ) ) {
+ tokenTuples.remove( tt );
+ tokenTuples.add(
+ new TokenTuple( token, true, TokenTuple.ARITY_MANY ).makeCanonical()
+ );
+ }
+
+ return makeCanonical();
+ }
+
public boolean equals( Object o ) {
if( !(o instanceof TokenTupleSet) ) {
return false;
return tokenTuples.hashCode();
}
+ /*
+ public boolean equalWithoutArity( TokenTupleSet ttsIn ) {
+ Iterator itrIn = ttsIn.iterator();
+ while( itrIn.hasNext() ) {
+ TokenTuple ttIn = (TokenTuple) itrIn.next();
+
+ if( !this.containsToken( ttIn.getToken() ) )
+ {
+ return false;
+ }
+ }
+
+ Iterator itrThis = this.iterator();
+ while( itrThis.hasNext() ) {
+ TokenTuple ttThis = (TokenTuple) itrThis.next();
+
+ if( !ttsIn.containsToken( ttThis.getToken() ) )
+ {
+ return false;
+ }
+ }
+
+ return true;
+ }
+ */
+
// this should be a hash table so we can do this by key
public boolean containsToken( Integer token ) {
Iterator itr = tokenTuples.iterator();