/** Reactivate this choice point to return new results. */
 public void pump() {
   if (context instanceof Generator) {
     ((Generator) context).pump(this);
   } else {
     // The top level iterator is in charge and will restore and run this choice point itself
   }
 }
 /**
  * Initialize the choice point state.
  *
  * @param interpreter the parent interpreter whose state is to be preserved here, its arg stack
  *     defines the parameters for the target goal
  */
 @Override
 public void init(LPInterpreter interpreter) {
   super.init(interpreter);
   context = interpreter.getContext();
   generator = interpreter.getEngine().generatorFor(goal);
   generator.addConsumer(this);
   resultIndex = 0;
 }
 /**
  * Find the next result triple and bind the result vars appropriately.
  *
  * @param interpreter the calling interpreter whose trail should be used
  * @return FAIL if there are no more matches and the generator is closed, SUSPEND if there are no
  *     more matches but the generator could generate more, SATISFIED if a match has been found.
  */
 public synchronized StateFlag nextMatch(LPInterpreter interpreter) {
   while (resultIndex < generator.results.size()) {
     Triple result = (Triple) generator.results.get(resultIndex++);
     // Check if we have finished with this generator
     if (resultIndex >= generator.results.size() && generator.isComplete()) {
       generator.removeConsumer(this);
     }
     if (bindResult(result, interpreter)) {
       return StateFlag.SATISFIED;
     }
   }
   if (generator.isComplete()) {
     setFinished();
     generator.removeConsumer(this);
     return StateFlag.FAIL;
   } else {
     return StateFlag.SUSPEND;
   }
 }
 /** Return true if this choice point could usefully be restarted. */
 public boolean isReady() {
   return generator.numResults() > resultIndex;
 }