public override bool Find(int val)
        {
            long time = System.Environment.TickCount;
            int local = 0;

            if (Size() == 0)
            {
                return false;
            }


            if (val > lastAdded || val < baseList.Get(0)) //Short Circuit case where its not in the set at all
            {
                //System.out.println("Time to perform BinarySearch for:"+val+":"+(System.nanoTime() - time));
                return false;
            }
            else if (val >= current_base) // We are in the set
            {

                int i = 0;
                for (i = 0; i < current_size; i++)
                {
                    local += current[i];

                    if (local > val)
                    {
                        break;
                    }
                }

                if (i == current_size)
                {
                    return local == val;
                }
                else
                {
                    return (local - current[i] == val);
                }
            }
            else // We are in the compressed space
            {
                if (baseList.Size() == 0)
                {
                    return false;
                }

                int blobIndex = BinarySearchForNearest(val, 0, blob.Size() - 1);

                local = baseList.Get(blobIndex);
                long[] @ref = blob.Get(blobIndex);
                P4DSetNoBase localCompressedSet = new P4DSetNoBase();
                localCompressedSet.SetParam(0, DEFAULT_B, BATCH_SIZE, BATCH_OVER);
                localCompressedSet.UpdateParams(@ref);

                int i = 0;

                for (i = 0; i < BATCH_SIZE; i++)
                {
                    local += localCompressedSet.Get(@ref, i);

                    if (local > val)
                    {
                        break;
                    }

                }
                if (i == BATCH_SIZE)
                {
                    return local == val;
                }
                else
                {
                    return (local - localCompressedSet.Get(@ref, i)) == val;
                }
            }
        }
Exemple #2
0
        public override bool Find(int val)
        {
            long time  = System.Environment.TickCount;
            int  local = 0;

            if (Size() == 0)
            {
                return(false);
            }


            if (val > lastAdded || val < baseList.Get(0)) //Short Circuit case where its not in the set at all
            {
                //System.out.println("Time to perform BinarySearch for:"+val+":"+(System.nanoTime() - time));
                return(false);
            }
            else if (val >= current_base) // We are in the set
            {
                int i = 0;
                for (i = 0; i < current_size; i++)
                {
                    local += current[i];

                    if (local > val)
                    {
                        break;
                    }
                }

                if (i == current_size)
                {
                    return(local == val);
                }
                else
                {
                    return(local - current[i] == val);
                }
            }
            else // We are in the compressed space
            {
                if (baseList.Size() == 0)
                {
                    return(false);
                }

                int blobIndex = BinarySearchForNearest(val, 0, blob.Size() - 1);

                local = baseList.Get(blobIndex);
                long[]       @ref = blob.Get(blobIndex);
                P4DSetNoBase localCompressedSet = new P4DSetNoBase();
                localCompressedSet.SetParam(0, DEFAULT_B, BATCH_SIZE, BATCH_OVER);
                localCompressedSet.UpdateParams(@ref);

                int i = 0;

                for (i = 0; i < BATCH_SIZE; i++)
                {
                    local += localCompressedSet.Get(@ref, i);

                    if (local > val)
                    {
                        break;
                    }
                }
                if (i == BATCH_SIZE)
                {
                    return(local == val);
                }
                else
                {
                    return((local - localCompressedSet.Get(@ref, i)) == val);
                }
            }
        }
 public P4DDocIdSet()
 {
     baseList = new IntArray();
     compressedSet = new P4DSetNoBase();
     compressedBits = 0;
 }
Exemple #4
0
 public P4DDocIdSet()
 {
     baseList       = new IntArray();
     compressedSet  = new P4DSetNoBase();
     compressedBits = 0;
 }