Beispiel #1
0
        private void Resize(int newSize)
        {
            var newArray = new HeapNode[newSize];

            for (var i = 0; i < m_Size; i++)
            {
                newArray[i] = nodes[i];
            }
            nodes      = newArray;
            m_Capacity = newSize;
        }
Beispiel #2
0
        public void Insert(ILabelled obj, float importance)
        {
            if (m_Size == m_Capacity)
            {
                Resize(2 * m_Size);
            }

            var i    = m_Size++;
            var node = new HeapNode(obj, importance);

            node.Object.Token = i;
            nodes[i]          = node;

            UpHeap(i);
        }