private int NextNonExcluded() { Debug.Assert(_candidates != null); Debug.Assert(_exclusions != null); var candidate = _candidates.Doc; var excluded = _exclusions.Doc; do { if (candidate < excluded) { return(candidate); // candidate before next exclusion } if (candidate > excluded) { excluded = _exclusions.Advance(candidate); if (excluded == NoMoreDocs) { _exclusions = null; // no more exclusions return(candidate); } if (candidate < excluded) { return(candidate); // candidate before next exclusion } } // else: candidate == excluded, try next candidate }while ((candidate = _candidates.NextDoc()) != NoMoreDocs); _candidates = null; // no more candidates return(NoMoreDocs); }
public override int Advance(int target) { if (_candidates == null) { return(Doc = NoMoreDocs); } if (_exclusions == null) { return(Doc = _candidates.Advance(target)); } if (_candidates.Advance(target) == NoMoreDocs) { _candidates = null; return(Doc = NoMoreDocs); } return(Doc = NextNonExcluded()); }
public override int NextDoc() { if (_candidates == null) { return(Doc = NoMoreDocs); } Doc = _candidates.NextDoc(); if (Doc == NoMoreDocs) { _candidates = null; // exhausted return(Doc); } if (_exclusions == null) { return(Doc); // nothing more to subtract } return(Doc = NextNonExcluded()); }
public ButNotIterator(DocSetIterator candidates, DocSetIterator exclusions) { _candidates = candidates; // can be null _exclusions = exclusions; // can be null }