private Tuple getNextTuple ( ) { if ( nextTuple_ == null ) { // Still traversing values for current start variable? int tupleSize = getTupleSize ( ) ; if ( ! ( values_ != null && values_ . hasNext ( ) ) ) { // No, still traversing subtuples for current start variable? values_ = null ; subTuple_ = null ; if ( ! ( subTuples_ != null && subTuples_ . hasNext ( ) ) ) { // No, advance to next start variable. subTuples_ = null ; varStart_ ++ ; if ( tupleSize > 1 ) { for ( ; varStart_ < varEnd_ && ( subTuples_ = new TupleIterator ( tupleSize - 1 , varDefs_ . subList ( varStart_ + 1 , varDefs_ . size ( ) ) , randSeq_ ) ) . hasNext ( ) == false ; varStart_ ++ ) ; } } } // More tuples remaining? if ( varStart_ < varEnd_ ) { VarDef startVarDef = varDefs_ . get ( varStart_ ) ; if ( values_ == null ) { // Resume traversing values for current start variable. values_ = RandSeq . reorderIf ( randSeq_ , startVarDef . getValidValues ( ) ) ; if ( ! values_ . hasNext ( ) ) { throw new IllegalStateException ( "Can't complete tuples -- no valid values defined for var=" + startVarDef ) ; } if ( tupleSize > 1 ) { // Advance to next subtuple for current start variable. subTuple_ = subTuples_ . next ( ) ; } } nextTuple_ = new Tuple ( ) ; nextTuple_ . add ( new VarBindingDef ( startVarDef , values_ . next ( ) ) ) ; if ( subTuple_ != null ) { nextTuple_ . addAll ( subTuple_ ) ; } } } return nextTuple_ ; }
Returns the next N - tuple of compatible values .