public void Alloc(uint newCapacity)
        {
            DBC.Common.Check.Require(buffer == null || buffer.ToNativeArray(out _) == IntPtr.Zero, "can't alloc an already allocated buffer");

            var    realBuffer = MemoryUtilities.Alloc((uint)(newCapacity * MemoryUtilities.SizeOf <T>()), Allocator.Persistent);
            NB <T> b          = new NB <T>(realBuffer, newCapacity);

            buffer          = b;
            this.realBuffer = b;
        }
        public void Resize(uint newCapacity, bool copyContent = true)
        {
            var pointer = _realBuffer.ToNativeArray(out _);

            pointer = MemoryUtilities.Realloc <T>(pointer, newCapacity, _nativeAllocator, (uint)capacity, copyContent);
            NB <T> b = new NB <T>(pointer, newCapacity);

            _realBuffer    = b;
            _invalidHandle = true;
        }
        public void Alloc(uint newCapacity, Allocator nativeAllocator)
        {
            _nativeAllocator = nativeAllocator;

            Check.Require(this._realBuffer.ToNativeArray(out _) == IntPtr.Zero
                          , "can't alloc an already allocated buffer");

            var realBuffer =
                MemoryUtilities.Alloc((uint)(newCapacity * MemoryUtilities.SizeOf <T>()), _nativeAllocator);
            NB <T> b = new NB <T>(realBuffer, newCapacity);

            _buffer          = IntPtr.Zero;
            this._realBuffer = b;
        }
        public void Alloc(uint newCapacity, Allocator allocator, bool clear = true)
        {
#if DEBUG && !PROFILE_SVELTO
            if (!(this._realBuffer.ToNativeArray(out _) == IntPtr.Zero))
            {
                throw new DBC.Common.PreconditionException("can't alloc an already allocated buffer");
            }
#endif
            _nativeAllocator = allocator;

            var    realBuffer = MemoryUtilities.Alloc <T>(newCapacity, _nativeAllocator, clear);
            NB <T> b          = new NB <T>(realBuffer, newCapacity);
            _buffer     = default;
            _realBuffer = b;
        }
        public void Resize(uint newCapacity)
        {
            Check.Require(newCapacity > 0, "Resize requires a size greater than 0");
            Check.Require(newCapacity > capacity, "can't resize to a smaller size");

            var pointer = _realBuffer.ToNativeArray(out _);
            var sizeOf  = MemoryUtilities.SizeOf <T>();

            pointer = MemoryUtilities.Realloc(pointer, (uint)(capacity * sizeOf), (uint)(newCapacity * sizeOf)
                                              , Allocator.Persistent);
            NB <T> b = new NB <T>(pointer, newCapacity);

            _buffer     = IntPtr.Zero;
            _realBuffer = b;
        }
        public void Alloc(uint newCapacity, Allocator nativeAllocator)
        {
#if DEBUG && !PROFILE_SVELTO
            if (!(this._realBuffer.ToNativeArray(out _) == IntPtr.Zero))
            {
                throw new PreconditionException("can't alloc an already allocated buffer");
            }
#endif
            _nativeAllocator = nativeAllocator;

            var realBuffer =
                MemoryUtilities.Alloc((uint)(newCapacity * MemoryUtilities.SizeOf <T>()), _nativeAllocator);
            NB <T> b = new NB <T>(realBuffer, newCapacity);
            _buffer     = default;
            _realBuffer = b;
        }
        public void AllocateMore(uint newSize, uint numberOfItemsToCopy, bool clear = true)
        {
#if DEBUG && !PROFILE_SVELTO
            if (newSize <= capacity)
            {
                throw new DBC.Common.PreconditionException("can't alloc more to a smaller or equal size");
            }
            if (numberOfItemsToCopy > capacity)
            {
                throw new DBC.Common.PreconditionException("out of bounds number of elements to copy");
            }
#endif
            var pointer = _realBuffer.ToNativeArray(out _);
            pointer = MemoryUtilities.Realloc <T>(pointer, newSize, _nativeAllocator, numberOfItemsToCopy, true, clear);
            NB <T> b = new NB <T>(pointer, newSize);
            _realBuffer    = b;
            _invalidHandle = true;
        }
        public void Resize(uint newCapacity, bool copyContent = true)
        {
#if DEBUG && !PROFILE_SVELTO
            if (!(newCapacity > 0))
            {
                throw new PreconditionException("Resize requires a size greater or equal to 0");
            }
            if (!(newCapacity > capacity))
            {
                throw new PreconditionException("can't resize to a smaller size");
            }
#endif
            var pointer = _realBuffer.ToNativeArray(out _);
            var sizeOf  = MemoryUtilities.SizeOf <T>();
            pointer = MemoryUtilities.Realloc(pointer, (uint)(capacity * sizeOf), (uint)(newCapacity * sizeOf)
                                              , _nativeAllocator, copyContent);
            NB <T> b = new NB <T>(pointer, newCapacity);
            _realBuffer    = b;
            _invalidHandle = true;
        }
Exemple #9
0
        public void Resize(uint newCapacity)
        {
#if DEBUG && !PROFILE_SVELTO
            if (!(newCapacity > 0))
            {
                throw new PreconditionException("Resize requires a size greater than 0");
            }
            if (!(newCapacity > capacity))
            {
                throw new PreconditionException("can't resize to a smaller size");
            }
#endif
            var pointer = _realBuffer.ToNativeArray(out _);
            var sizeOf  = MemoryUtilities.SizeOf <T>();
            pointer = MemoryUtilities.Realloc(pointer, (uint)(capacity * sizeOf), (uint)(newCapacity * sizeOf)
                                              , Allocator.Persistent);
            NB <T> b = new NB <T>(pointer, newCapacity);
            _buffer     = IntPtr.Zero;
            _realBuffer = b;
        }
Exemple #10
0
 public NBDebugProxy(NB <T> array)
 {
     this.m_Array = array;
 }