public boolean nextP() {
    { QuerySolutionTableIterator self = this;

      { QuerySolutionTable table = self.theTable;
        QuerySolution cursor = self.cursor;
        QuerySolution previous = cursor;

        if (self.firstIterationP) {
          previous = null;
          cursor = table.first;
          self.firstIterationP = false;
        }
        else {
          previous = cursor;
          cursor = cursor.next;
        }
        while ((cursor != null) &&
            cursor.deletedP()) {
          cursor = cursor.next;
        }
        self.cursor = cursor;
        if (cursor != null) {
          if (previous == null) {
            table.first = cursor;
          }
          else {
            previous.next = cursor;
          }
          self.key = cursor.bindings;
          self.value = cursor;
          return (true);
        }
        else if (previous != null) {
          previous.next = null;
          table.last = previous;
        }
        return (false);
      }
    }
  }