예제 #1
0
 public NativePairBuffer(int length, Allocator allocator, NativeArrayOptions options = NativeArrayOptions.ClearMemory)
 {
     _headSize = UnsafeUtility.SizeOf <THead>();
     _buffer   = new NativeBuffer <Pair>(length, allocator, options);
 }
 public NativeBufferDebugView(NativeBuffer <T> buffer)
 {
     Buffer = buffer;
 }
예제 #3
0
 public unsafe NativePairBuffer(void *ptr, int elementCount)
 {
     _headSize = UnsafeUtility.SizeOf <THead>();
     _buffer   = new NativeBuffer <Pair>(ptr, elementCount);
 }
 public NativeBuffer(int length, Allocator allocator, NativeArrayOptions options = NativeArrayOptions.ClearMemory)
 {
     _buffer   = NativeBuffer.Create <T>(length, allocator, options);
     _maxIndex = -1;
 }
 public void CopyFrom(NativeBuffer <T> source)
 {
     source._buffer.CopyTo <T>(_buffer);
     _maxIndex = source._maxIndex;
 }
        //public struct DefaultComparer<T> : IComparer<T> where T : IComparable<T>
        //{
        //    public int Compare(T x, T y) => x?.CompareTo(y) ?? 0;
        //}

        //unsafe public static void Sort<T>(this NativeBuffer<T> array) where T : struct, IComparable<T>
        //{
        //    array.Sort(new DefaultComparer<T>());
        //}

        unsafe public static void Sort <T, U>(this NativeBuffer <T> array, U comp) where T : struct where U : IComparer <T>
        {
            IntroSort <T, U>(array.GetUnsafePtr(), 0, array.Length - 1, 2 * math_2.log2_floor(array.Length), comp);
        }
 /// <summary>
 /// Initialize the buffer with a preallocated memory space (e.g. stackalloc ptr)
 /// </summary>
 /// <param name="ptr">starting address of the allocated memory</param>
 /// <param name="elementCount">number of T sized elements in the allocation</param>
 public unsafe NativeBuffer(void *ptr, int elementCount)
 {
     _buffer   = NativeBuffer.Assign <T>(ptr, elementCount);
     _maxIndex = -1;
 }
 public NativeBufferEnumerator(ref NativeBuffer <T> buffer)
 {
     _source = buffer;
     _index  = -1;
 }