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 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; } } }
/////<summary>Method to allow iteration in decompressed form</summary> //public int get(OpenBitSet set, int index) //{ // return localCompressedSet.Get(set, index); //} ///<summary>Method to allow iteration in decompressed form </summary> public virtual int @get(long[] @set, int index) { return(localCompressedSet.Get(@set, index)); }