示例#1
0
        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);
        }
示例#2
0
        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());
        }