Exemplo n.º 1
0
        ///
        ///<summary>Find existence in the set with index
        ///   *
        ///   * NOTE :  Expensive call. Avoid. </summary>
        ///   * <param name="val"> value to find the index for </param>
        ///   * <returns> index where the value is </returns>
        ///
        public override int FindWithIndex(int val)
        {
            DocIdSetIterator finder = new AndDocIdSetIterator(this);
            int cursor = -1;

            try
            {
                int docid;
                while ((docid = finder.NextDoc()) != DocIdSetIterator.NO_MORE_DOCS)
                {
                    if (docid > val)
                    {
                        return(-1);
                    }
                    else if (docid == val)
                    {
                        return(++cursor);
                    }
                    else
                    {
                        ++cursor;
                    }
                }
            }
            catch
            {
                return(-1);
            }
            return(-1);
        }
Exemplo n.º 2
0
        public override bool Find(int val)
        {
            DocIdSetIterator finder = new AndDocIdSetIterator(this);

            try
            {
                int docid = finder.Advance(val);
                if (docid != DocIdSetIterator.NO_MORE_DOCS && docid == val)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch
            {
                return(false);
            }
        }