Exemplo n.º 1
0
        public void Shrink()
        {
            var newSize = EcsHelpers.GetPowerOfTwoSize(_itemsCount < MinSize ? MinSize : _itemsCount);

            if (newSize < Items.Length)
            {
                Array.Resize(ref Items, newSize);
            }
            if (_reservedItems.Length > MinSize)
            {
                _reservedItems      = new int[MinSize];
                _reservedItemsCount = 0;
            }
        }
Exemplo n.º 2
0
        public void Shrink()
        {
            var newSize = EcsHelpers.GetPowerOfTwoSize(_itemsCount < MinSize ? MinSize : _itemsCount);

            if (newSize < Items.Length)
            {
                var newItems = new T[newSize];
                Array.Copy(Items, 0, newItems, 0, _itemsCount);
                Items = newItems;
            }
            if (_reservedItems.Length > MinSize)
            {
                _reservedItems      = new int[MinSize];
                _reservedItemsCount = 0;
            }
        }
Exemplo n.º 3
0
        public EcsEntityHashSet(int capacity = 0)
        {
            if (capacity < MinCapacity)
            {
                capacity = MinCapacity;
            }
            var size = EcsHelpers.GetPowerOfTwoSize(capacity);

            _buckets = new int[size];
            for (var i = 0; i < _buckets.Length; i++)
            {
                _buckets[i] = -1;
            }
            _entries  = new Entry[size];
            _freeList = -1;
        }