public void used ( Tuple tuple ) { // Currently unused? int i = unused_ . indexOf ( tuple ) ; if ( i >= 0 ) { // Yes, relocate to used list. unused_ . remove ( i ) ; addUsed ( tuple ) ; if ( tuple . size ( ) > 1 ) { // Once used, N-tuples can be reduced to 1-tuples. This enables different combinations // that may be required to complete tests for other tuples. In particular, it allows for an // NA binding of an optional variable, which will never appear in N-tuples. for ( Iterator < VarBindingDef > bindings = tuple . getBindings ( ) ; bindings . hasNext ( ) ; ) { Tuple tuple1 = new Tuple ( bindings . next ( ) ) ; tuple1 . setOnce ( tuple . isOnce ( ) ) ; // 1-tuple already used? if ( ( i = used_ . indexOf ( tuple1 ) ) >= 0 ) { // Yes, move to the end of the list. This acts to keep the used list // in least-recently-used-first order. used_ . remove ( i ) ; } addUsed ( tuple1 ) ; } } } // No, already used? else if ( ( i = used_ . indexOf ( tuple ) ) >= 0 ) { // Yes, move to the end of the list. This acts to keep the used list // in least-recently-used-first order. addUsed ( used_ . remove ( i ) ) ; } }
Asserts that the given tuple has been used in a test case .