예제 #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 if the given value </returns>
        ///
        public override int FindWithIndex(int val)
        {
            DocIdSetIterator finder = new NotDocIdSetIterator(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);
        }
예제 #2
0
        /// <summary>
        /// Find existence in the set with index
        ///
        /// NOTE :  Expensive call. Avoid.
        /// </summary>
        /// <param name="target">value to find the index for</param>
        /// <returns>index if the given value</returns>
        public override int FindWithIndex(int target)
        {
            DocIdSetIterator finder = new NotDocIdSetIterator(this.m_innerSet, () => this.m_max);
            int cursor = -1;

            try
            {
                int docid;
                while ((docid = finder.NextDoc()) != DocIdSetIterator.NO_MORE_DOCS)
                {
                    if (docid > target)
                    {
                        return(-1);
                    }
                    else if (docid == target)
                    {
                        return(++cursor);
                    }
                    else
                    {
                        ++cursor;
                    }
                }
            }
            catch (Exception)
            {
                return(-1);
            }
            return(-1);
        }
예제 #3
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 if the given value </returns>
        ///   
        public override int FindWithIndex(int val)
        {
            DocIdSetIterator finder = new NotDocIdSetIterator(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;
        }