コード例 #1
0
        public static void CopyWithIndex <T, TCopy>(NativeBufferArray <T> fromArr, ref NativeBufferArray <T> arr, TCopy copy) where TCopy : IArrayElementCopyWithIndex <T> where T : struct
        {
            if (fromArr.isCreated == false)
            {
                if (arr.isCreated == true)
                {
                    NativeArrayUtils.RecycleWithIndex(ref arr, copy);
                }
                arr = NativeBufferArray <T> .Empty;
                return;
            }

            if (arr.isCreated == false || fromArr.Length != arr.Length)
            {
                if (arr.isCreated == true)
                {
                    NativeArrayUtils.RecycleWithIndex(ref arr, copy);
                }
                arr = PoolArrayNative <T> .Spawn(fromArr.Length);
            }

            for (int i = 0; i < fromArr.Length; ++i)
            {
                copy.Copy(i, fromArr.arr[i], ref arr.arr.GetRef(i));
            }
        }
コード例 #2
0
 public void Recycle(ref NativeBufferArray <T> value)
 {
     if (value != null)
     {
         value.Dispose();
     }
 }
コード例 #3
0
 public static void Recycle(ref NativeBufferArray <T> buffer)
 {
     if (buffer.isCreated == true)
     {
         buffer.Dispose();
     }
     buffer = NativeBufferArray <T> .Empty;
 }
コード例 #4
0
        public static void RecycleWithIndex <T, TCopy>(ref NativeBufferArray <T> item, TCopy copy) where TCopy : IArrayElementCopyWithIndex <T> where T : struct
        {
            for (int i = 0; i < item.Length; ++i)
            {
                copy.Recycle(i, ref item.arr.GetRef(i));
            }

            item = item.Dispose();
        }
コード例 #5
0
        public static void Recycle <T, TCopy>(ref NativeBufferArray <T> item, TCopy copy) where TCopy : IArrayElementCopy <T> where T : struct
        {
            for (int i = 0; i < item.Length; ++i)
            {
                copy.Recycle(item.arr[i]);
            }

            item = item.Dispose();
        }
コード例 #6
0
        public static NativeBufferArray <T> Spawn(int length, bool realSize = false, Unity.Collections.Allocator allocator = Unity.Collections.Allocator.Persistent)
        {
            var arrSize = PoolArray <T> .GetSize(length);

            var arr    = new Unity.Collections.NativeArray <T>(arrSize, allocator);
            var size   = (realSize == true ? arr.Length : length);
            var buffer = new NativeBufferArray <T>(arr, length, realSize == true ? arr.Length : -1);

            NativeArrayUtils.Clear(buffer, 0, size);

            return(buffer);
        }
コード例 #7
0
 public static void Clear <T>(NativeBufferArray <T> arr, int index, int length) where T : struct
 {
     arr.Clear(index, length);
 }
コード例 #8
0
 public static void Clear <T>(NativeBufferArray <T> arr) where T : struct
 {
     arr.Clear();
 }
コード例 #9
0
 public void Clone(NativeBufferArray <T> from, ref NativeBufferArray <T> to)
 {
     to = NativeBufferArray <T> .From(from);
 }
コード例 #10
0
 public void Set(NativeBufferArray <T> value)
 {
     this.dataObject.Set(value);
 }
コード例 #11
0
 public NativeDataBufferArray(NativeBufferArray <T> data)
 {
     this.dataObject = new DataObject <NativeBufferArray <T>, NativeDataBufferArrayProvider <T> >(data);
     this.Length     = data.Length;
 }
コード例 #12
0
 public Enumerator(NativeBufferArray <T> bufferArray)
 {
     this.bufferArray = bufferArray;
     this.index       = -1;
 }