Ejemplo n.º 1
0
        //============================================================================
        // getObjNearAddress
        //============================================================================
        public object getObjNearAddress(uint address)
        {
            uint hashKey = getHashKey(address);

            SortedBinaryTree ab = (SortedBinaryTree)mAddressBuckets[hashKey];

            if (ab == null)
            {
                return(null);
            }

            return(ab.getObjectNearValue(address));
        }
Ejemplo n.º 2
0
        //============================================================================
        // addAddress
        //============================================================================
        public bool addAddress(uint addr, object obj)
        {
            uint hashKey = getHashKey(addr);

            if (!mAddressBuckets.Contains(hashKey))
            {
                mAddressBuckets.Add(hashKey, new SortedBinaryTree());
                if (hashKey < mMinBucket)
                {
                    mMinBucket = hashKey;
                }
                if (hashKey > mMaxBucket)
                {
                    mMaxBucket = hashKey;
                }
                if (mAddressBuckets.Count >= mNumBuckets)
                {
                    return(false);
                }
            }

            SortedBinaryTree ab = (SortedBinaryTree)mAddressBuckets[hashKey];

            ab.addValue(addr, obj);
            if (ab.count() >= mRangePerBucket)
            {
                return(false);
            }
            if (addr < mMinSearched)
            {
                mMinSearched = addr;
            }
            if (addr > mMaxSearched)
            {
                mMaxSearched = addr;
            }
            if (ab.count() > mMaxEntriesInBucket)
            {
                mMaxEntriesInBucket = (uint)ab.count();
            }

            return(true);
        }