public unsafe Chunk *GetChunkWithEmptySlots(int *sharedComponentDataIndices, int numSharedComponents)
        {
            uint  hashCode = this.GetHashCode(sharedComponentDataIndices, numSharedComponents);
            Node *buckets  = this.buckets + ((hashCode & this.hashMask) * sizeof(Node));
            Node *nodePtr2 = this.buckets + (this.hashMask * sizeof(Node));

            while (true)
            {
                Chunk *chunkFromEmptySlotNode;
                if (buckets.IsFree())
                {
                    chunkFromEmptySlotNode = null;
                }
                else
                {
                    if (!(!buckets.IsDeleted() && buckets.CheckEqual(hashCode, sharedComponentDataIndices, numSharedComponents)))
                    {
                        buckets++;
                        if (buckets <= nodePtr2)
                        {
                            continue;
                        }
                        buckets = this.buckets;
                        continue;
                    }
                    chunkFromEmptySlotNode = ArchetypeManager.GetChunkFromEmptySlotNode(buckets->list.Begin);
                }
                return(chunkFromEmptySlotNode);
            }
        }
        private unsafe void AddMultiple(UnsafeLinkedListNode *list)
        {
            Chunk *chunkPtr = ref ArchetypeManager.GetChunkFromEmptySlotNode(list.Begin);
            uint   hashCode = this.GetHashCode(chunkPtr->SharedComponentValueArray, chunkPtr->Archetype.NumSharedComponents);
            int *  sharedComponentValueArray = chunkPtr->SharedComponentValueArray;
            int    numSharedComponents       = chunkPtr->Archetype.NumSharedComponents;
            Node * buckets  = this.buckets + ((hashCode & this.hashMask) * sizeof(Node));
            Node * nodePtr2 = this.buckets + (this.hashMask * sizeof(Node));
            Node * nodePtr3 = null;

            while (true)
            {
                if (buckets.IsFree())
                {
                    if (nodePtr3 == null)
                    {
                        nodePtr3 = buckets;
                        this.emptyNodes--;
                    }
                    nodePtr3->hash = hashCode;
                    UnsafeLinkedListNode.InitializeList(&nodePtr3->list);
                    UnsafeLinkedListNode.InsertListBefore(nodePtr3->list.End, list);
                    if (this.ShouldGrow(this.emptyNodes))
                    {
                        this.Grow();
                    }
                    break;
                }
                if (!buckets.IsDeleted())
                {
                    if (buckets.CheckEqual(hashCode, sharedComponentValueArray, numSharedComponents))
                    {
                        UnsafeLinkedListNode.InsertListBefore(buckets->list.End, list);
                        break;
                    }
                }
                else if (nodePtr3 == null)
                {
                    nodePtr3 = buckets;
                }
                buckets++;
                if (buckets > nodePtr2)
                {
                    buckets = this.buckets;
                }
            }
        }
        public unsafe void Add(Chunk *chunk)
        {
            int * sharedComponentValueArray = chunk.SharedComponentValueArray;
            int   numSharedComponents       = chunk.Archetype.NumSharedComponents;
            uint  hashCode = this.GetHashCode(sharedComponentValueArray, numSharedComponents);
            Node *buckets  = this.buckets + ((hashCode & this.hashMask) * sizeof(Node));
            Node *nodePtr2 = this.buckets + (this.hashMask * sizeof(Node));
            Node *nodePtr3 = null;

            while (true)
            {
                if (buckets.IsFree())
                {
                    if (nodePtr3 == null)
                    {
                        nodePtr3 = buckets;
                        this.emptyNodes--;
                    }
                    nodePtr3->hash = hashCode;
                    UnsafeLinkedListNode.InitializeList(&nodePtr3->list);
                    nodePtr3->list.Add(&chunk.ChunkListWithEmptySlotsNode);
                    if (this.ShouldGrow(this.emptyNodes))
                    {
                        this.Grow();
                    }
                    break;
                }
                if (!buckets.IsDeleted())
                {
                    if (buckets.CheckEqual(hashCode, sharedComponentValueArray, numSharedComponents))
                    {
                        buckets->list.Add(&chunk.ChunkListWithEmptySlotsNode);
                        break;
                    }
                }
                else if (nodePtr3 == null)
                {
                    nodePtr3 = buckets;
                }
                buckets++;
                if (buckets > nodePtr2)
                {
                    buckets = this.buckets;
                }
            }
        }