Example #1
0
        void Init(int initialHashSize, int initialIndexSize)
        {
            Debug.Assert(MathX.IsPowerOfTwo(initialHashSize));

            hashSize    = initialHashSize;
            hash        = INVALID_INDEX;
            indexSize   = initialIndexSize;
            indexChain  = INVALID_INDEX;
            granularity = DEFAULT_HASH_GRANULARITY;
            hashMask    = hashSize - 1;
            lookupMask  = 0;
        }
Example #2
0
        unsafe void Allocate(int newHashSize, int newIndexSize)
        {
            Debug.Assert(MathX.IsPowerOfTwo(newHashSize));

            Free();
            hashSize = newHashSize;
            hash     = new int[hashSize];

            fixed(void *hash_ = hash) Unsafe.InitBlock(hash_, 0xff, (uint)(hashSize * sizeof(int)));

            indexSize  = newIndexSize;
            indexChain = new int[indexSize];

            fixed(void *indexChain_ = indexChain) Unsafe.InitBlock(indexChain_, 0xff, (uint)(indexSize * sizeof(int)));

            hashMask   = hashSize - 1;
            lookupMask = -1;
        }