Beispiel #1
0
        private void Copy(NativeFasterDictionaryData *src, NativeFasterDictionaryData *dst)
        {
            if (src->Layout.AllocationBytes > dst->Layout.AllocationBytes)
            {
                throw new Exception("Shrinking allocation is not supported");
            }

            dst->FreeValueCellIndex = src->FreeValueCellIndex;
            dst->Collisions         = src->Collisions;

            UnsafeUtility.MemCpy(dst->Nodes.GetUnsafePtr(), src->Nodes.GetUnsafePtr(), src->Layout.NodesBytes);
            UnsafeUtility.MemCpy(dst->Values.GetUnsafePtr(), src->Values.GetUnsafePtr(), src->Layout.ValuesBytes);
            UnsafeUtility.MemCpy(dst->Buckets.GetUnsafePtr(), src->Buckets.GetUnsafePtr(), src->Layout.BucketsBytes);
        }
Beispiel #2
0
        public void Expand(int newSize)
        {
            if (newSize <= Data->Capacity)
            {
                return;
            }

            var newData = Allocate(newSize, _allocator);
            var oldData = Data;

            Copy(oldData, newData);

            Data = newData;

            UnsafeUtility.Free(oldData, _allocator);
        }
Beispiel #3
0
 public NativeFasterDictionary(int size, Allocator allocator) : this()
 {
     Data       = Allocate(size, allocator);
     _allocator = allocator;
     _isCreated = 1;
 }