/**
 * Advances to the next document matching the query. <br>
 *
 * @return the document matching the query or NO_MORE_DOCS if there are no more documents.
 */
181410
func (ts *TermScorer) NextDoc() (d int, err error) {
	return ts.docsEnum.NextDoc()
}
116872
func (itr *queryResultsItr) Next() (commonledger.QueryResult, error) {

	queryResult, err := itr.DBItr.Next()
	if err != nil {
		return nil, err
	}
	if queryResult == nil {
		return nil, nil
	}
	versionedQueryRecord := queryResult.(*statedb.VersionedKV)
	logger.Debugf("queryResultsItr.Next() returned a record:%s", string(versionedQueryRecord.Value))

	if itr.RWSetBuilder != nil {
		itr.RWSetBuilder.AddToReadSet(versionedQueryRecord.Namespace, versionedQueryRecord.Key, versionedQueryRecord.Version)
	}
	return &queryresult.KV{Namespace: versionedQueryRecord.Namespace, Key: versionedQueryRecord.Key, Value: versionedQueryRecord.Value}, nil
}
1372313
func (iterator *LinkedBlockingDequeIterator) Next() interface{} {
	if iterator.next == nil {
		//TODO error or nil ?
		//panic(errors.New("NoSuchElement"))
		return nil
	}
	iterator.lastRet = iterator.next
	x := iterator.nextItem
	iterator.advance()
	return x
}
1017322
func (i *DictionaryIterator) Next() (*index.DictEntry, error) {
	if i.err != nil && i.err != vellum.ErrIteratorDone {
		return nil, i.err
	} else if i.itr == nil || i.err == vellum.ErrIteratorDone {
		return nil, nil
	}
	term, postingsOffset := i.itr.Current()
	i.entry.Term = string(term)
	if !i.omitCount {
		i.err = i.tmp.read(postingsOffset, i.d)
		if i.err != nil {
			return nil, i.err
		}
		i.entry.Count = i.tmp.Count()
	}
	i.err = i.itr.Next()
	return &i.entry, nil
}
614341
func (list *DocumentList) Find(id string) *Document {
	for _, item := range list.Data {
		if item.ID == id {
			return item
		}
	}

	return nil
}
836288
public synchronized Document next() {
        Document next = new StringDocument(nextLine);
        try {
            nextLine = advance();
        } catch (IOException ioe) {
            throw new IOError(ioe);
        }
        return next;
    }
95126
private boolean goToNextDoc() throws IOException {
    if (docId == NO_MORE_DOCS) {
      return true;
    } else {
      // try to find docId with match for all items from sequence
      Integer spanDocId;
      Integer newDocId = null;
      Integer minOptionalDocId = null;
      boolean allItemsOptional = true;
      for (QueueItem item : queueSpans) {
        if (!item.sequenceSpans.optional) {
          allItemsOptional = false;
        }
        if (!item.noMoreDocs) {
          if (item.sequenceSpans.spans == null) {
            spanDocId = NO_MORE_DOCS;
          } else if (newDocId == null) {
            spanDocId = item.sequenceSpans.spans.nextDoc();
          } else {
            if (!item.sequenceSpans.optional) {
              spanDocId = item.sequenceSpans.spans.advance(newDocId);
            } else {
              if (item.sequenceSpans.spans.docID() == -1
                  || newDocId > item.sequenceSpans.spans.docID()) {
                spanDocId = item.sequenceSpans.spans.advance(newDocId);
              } else {
                spanDocId = item.sequenceSpans.spans.docID();
              }
            }
          }
          if (spanDocId.equals(NO_MORE_DOCS)) {
            item.noMoreDocs = true;
            if (!item.sequenceSpans.optional) {
              // a not optional span has NO_MORE_DOCS: stop
              docId = NO_MORE_DOCS;
              return true;
            }
          } else if (!spanDocId.equals(newDocId)) {
            // last found spanDocId not equal to potential new docId
            if (newDocId != null) {
              if (!item.sequenceSpans.optional) {
                // move also previous spans to at least spanDocId
                advance(spanDocId);
                return true;
              }
              // define potential new docId
            } else {
              if (!item.sequenceSpans.optional) {
                // previous optional span with lower docId
                if ((minOptionalDocId != null)
                    && (minOptionalDocId < spanDocId)) {
                  advance(spanDocId);
                  return true;
                } else {
                  // use spanDocId as potential newDocId
                  newDocId = spanDocId;
                }
              } else {
                // remember minimum docId optional spans
                minOptionalDocId = (minOptionalDocId == null) ? spanDocId
                    : Math.min(minOptionalDocId, spanDocId);
              }
            }
          }
        }
      }
      // if all items are optional
      if (allItemsOptional && newDocId == null && minOptionalDocId != null) {
        newDocId = minOptionalDocId;
      }
      // nothing found
      if (newDocId == null) {
        docId = NO_MORE_DOCS;
        return true;
      } else {
        docId = newDocId;
        ignoreItem.advanceToDoc(docId);
        // try and glue together
        if (findMatches()) {
          return true;
          // no matches
        } else {
          resetQueue();
          return false;
        }
      }
    }
  }
1006381
func (iter *PermutationIterator) Next() []interface{} {
	if !iter.HasNext() {
		return nil
	}

	if iter.res[0] != nil {
		for i := iter.r - 1; i > -1; i-- {
			iter.cycles[i] -= 1
			if iter.cycles[i] == 0 {
				for x := i; x < iter.n-1; x++ {
					v := iter.indices[x]
					iter.indices[x] = iter.indices[x+1]
					iter.indices[x+1] = v
				}
				iter.cycles[i] = iter.n - i
			} else {
				x := iter.indices[i]
				iter.indices[i] = iter.indices[iter.n-iter.cycles[i]]
				iter.indices[iter.n-iter.cycles[i]] = x
				break
			}
		}
	}

	for i := 0; i < iter.r; i++ {
		iter.res[i] = iter.pool[iter.indices[i]]
	}

	iter.iters += 1

	return iter.res
}
643260
func (iter *s3DeleteVersionListIterator) Next() bool {
	if len(iter.objects) > 0 {
		iter.objects = iter.objects[1:]
	}

	if len(iter.objects) == 0 && iter.Paginator.Next() {
		output := iter.Paginator.Page().(*s3.ListObjectVersionsOutput)
		iter.objects = output.Versions

		for _, entry := range output.DeleteMarkers {
			iter.objects = append(iter.objects, &s3.ObjectVersion{
				Key:       entry.Key,
				VersionId: entry.VersionId,
			})
		}
	}

	return len(iter.objects) > 0
}
96151
func (d *document) Query(pattern string) (PathValues, error) {
	pvs := PathValues{}
	err := d.Process(func(path string, value Value) error {
		if stringex.Matches(pattern, path, false) {
			pvs = append(pvs, PathValue{
				Path:  path,
				Value: value,
			})
		}
		return nil
	})
	return pvs, err
}
823418
func Next() string {
	globalNUID.Lock()
	nuid := globalNUID.Next()
	globalNUID.Unlock()
	return nuid
}
234973
func (itr *mergeSegmentIterator) next() (s0, s1 *rowSegment) {
	// Find current segments.
	if len(itr.a0) > 0 {
		s0 = &itr.a0[0]
	}
	if len(itr.a1) > 0 {
		s1 = &itr.a1[0]
	}

	// Return if either or both are nil.
	if s0 == nil && s1 == nil {
		return
	} else if s0 == nil {
		itr.a1 = itr.a1[1:]
		return
	} else if s1 == nil {
		itr.a0 = itr.a0[1:]
		return
	}

	// Otherwise determine which is first.
	if s0.shard < s1.shard {
		itr.a0 = itr.a0[1:]
		return s0, nil
	} else if s0.shard > s1.shard {
		itr.a1 = itr.a1[1:]
		return s1, nil
	}

	// Return both if shards are equal.
	itr.a0, itr.a1 = itr.a0[1:], itr.a1[1:]
	return s0, s1
}
669848
func (e *UpdateExec) Next(ctx context.Context, req *chunk.RecordBatch) error {
	if span := opentracing.SpanFromContext(ctx); span != nil && span.Tracer() != nil {
		span1 := span.Tracer().StartSpan("update.Next", opentracing.ChildOf(span.Context()))
		defer span1.Finish()
	}

	req.Reset()
	if !e.fetched {
		err := e.fetchChunkRows(ctx)
		if err != nil {
			return err
		}
		e.fetched = true
		e.ctx.GetSessionVars().StmtCtx.AddRecordRows(uint64(len(e.rows)))

		for {
			row, err := e.exec(e.children[0].Schema())
			if err != nil {
				return err
			}

			// once "row == nil" there is no more data waiting to be updated,
			// the execution of UpdateExec is finished.
			if row == nil {
				break
			}
		}
	}

	return nil
}
1261220
func (itr *tagKeySliceIterator) Next() ([]byte, error) {
	if len(itr.keys) == 0 {
		return nil, nil
	}
	key := itr.keys[0]
	itr.keys = itr.keys[1:]
	return key, nil
}
142990
func (c *KeyCursor) Next() {
	if len(c.current) == 0 {
		return
	}
	// Do we still have unread values in the current block
	if !c.current[0].read() {
		return
	}
	c.current = c.current[:0]
	if c.ascending {
		c.nextAscending()
	} else {
		c.nextDescending()
	}
}
414074
func (r *responseIterator) Next() flux.Result {
	res := r.response.Results[r.resultIdx]
	r.resultIdx++
	return newQueryResult(&res)
}
636510
func (i *PostingsIterator) nextDocNumAtOrAfter(atOrAfter uint64) (uint64, bool, error) {
	if i.normBits1Hit != 0 {
		if i.docNum1Hit == DocNum1HitFinished {
			return 0, false, nil
		}
		if i.docNum1Hit < atOrAfter {
			// advanced past our 1-hit
			i.docNum1Hit = DocNum1HitFinished // consume our 1-hit docNum
			return 0, false, nil
		}
		docNum := i.docNum1Hit
		i.docNum1Hit = DocNum1HitFinished // consume our 1-hit docNum
		return docNum, true, nil
	}

	if i.Actual == nil || !i.Actual.HasNext() {
		return 0, false, nil
	}

	if i.postings == nil || i.postings.postings == i.ActualBM {
		return i.nextDocNumAtOrAfterClean(atOrAfter)
	}

	n := i.Actual.Next()
	for uint64(n) < atOrAfter && i.Actual.HasNext() {
		n = i.Actual.Next()
	}
	if uint64(n) < atOrAfter {
		// couldn't find anything
		return 0, false, nil
	}
	allN := i.all.Next()

	nChunk := n / i.postings.sb.chunkFactor

	// when allN becomes >= to here, then allN is in the same chunk as nChunk.
	allNReachesNChunk := nChunk * i.postings.sb.chunkFactor

	// n is the next actual hit (excluding some postings), and
	// allN is the next hit in the full postings, and
	// if they don't match, move 'all' forwards until they do
	for allN != n {
		// we've reached same chunk, so move the freq/norm/loc decoders forward
		if i.includeFreqNorm && allN >= allNReachesNChunk {
			err := i.currChunkNext(nChunk)
			if err != nil {
				return 0, false, err
			}
		}

		allN = i.all.Next()
	}

	if i.includeFreqNorm && (i.currChunk != nChunk || i.currChunkFreqNorm == nil) {
		err := i.loadChunk(int(nChunk))
		if err != nil {
			return 0, false, fmt.Errorf("error loading chunk: %v", err)
		}
	}

	return uint64(n), true, nil
}