Exemplo n.º 1
0
 public MinHeap(int maxDepth, Allocator allocator)
 {
     objs        = UnsafeUtilityEx.AllocArray <KdQueryNode>(maxDepth + 1, allocator);
     heap        = UnsafeUtilityEx.AllocArray <float>(maxDepth + 1, allocator);
     Count       = 0;
     m_allocator = allocator;
 }
Exemplo n.º 2
0
        public MinMaxHeap(int startCapacity, Allocator allocator)
        {
            Count       = 0;
            m_allocator = allocator;

            // Now alloc starting arrays
            m_capacity = startCapacity;
            values     = UnsafeUtilityEx.AllocArray <float>(startCapacity + 1, m_allocator);
            keys       = UnsafeUtilityEx.AllocArray <T>(startCapacity + 1, m_allocator);
        }
Exemplo n.º 3
0
        public KSmallestHeap(int maxEntries, Allocator allocator)
        {
            maxSize     = maxEntries;
            m_allocator = allocator;

            heap        = UnsafeUtilityEx.AllocArray <float>(maxEntries + 1, allocator);
            objs        = UnsafeUtilityEx.AllocArray <int>(maxEntries + 1, allocator);
            m_allocator = allocator;

            Count = 0;
        }
Exemplo n.º 4
0
        public void Resize(int newSize)
        {
            // Allocate more space
            var newValues = UnsafeUtilityEx.AllocArray <float>(newSize + 1, m_allocator);
            var newKeys   = UnsafeUtilityEx.AllocArray <T>(newSize + 1, m_allocator);

            // Copy over old arrays
            UnsafeUtility.MemCpy(newValues, values, (m_capacity + 1) * sizeof(int));
            UnsafeUtility.MemCpy(newKeys, keys, (m_capacity + 1) * sizeof(int));

            // Get rid of old arrays
            Dispose();

            // And now use old arrays
            values     = newValues;
            keys       = newKeys;
            m_capacity = newSize;
        }