private E nextInternal ( ) { // Check if the next soluation has already been cached, because of a call to hasNext. if ( nextSolution != null ) { return nextSolution ; } // Otherwise, generate the next solution, if possible. nextSolution = nextInSequence ( ) ; // Check if the solution was null, which indicates that the search space is exhausted. if ( nextSolution == null ) { exhausted = true ; } return nextSolution ; }
Gets the next element from the sequence the cached one if one has already been generated or creating and caching a new one if not . If the cached element from a previous call has not been consumed then subsequent calls to this method will not advance the iterator .