public int nextDoc() {while (true) {if (queue.size() == 0) {doc = NO_MORE_DOCS;break;}int newDoc = queue.top().docID();if (newDoc != doc) {assert newDoc > doc: "doc=" + doc + " newDoc=" + newDoc;doc = newDoc;break;}if (queue.top().nextDoc() == NO_MORE_DOCS) {queue.pop();} else {queue.updateTop();}}return doc;}

public override int NextDoc(){if (idx >= size){offset = -1;return doc = DocIdSetIterator.NO_MORE_DOCS;}doc = (int)docs.Get(idx);++idx;while (idx < size && docs.Get(idx) == doc){++idx;}long prevIdx = idx - 1;if (!docsWithField.Get((int)prevIdx)){offset = -1;}else{offset = (int)offsets.Get(prevIdx);length = (int)lengths.Get(prevIdx);}return doc;}
