コード例 #1
0
ファイル: PriorityQueue.cs プロジェクト: Amitkapadi/WISP
 private void growHeap()
 {
     m_Capacity = (m_Capacity * 2) + 1;
     HeapEntry <Titem>[] newHeap = new HeapEntry <Titem> [m_Capacity];
     System.Array.Copy(m_Heap, 0, newHeap, 0, (int)m_Count);
     m_Heap = newHeap;
 }
コード例 #2
0
ファイル: PriorityQueue.cs プロジェクト: Amitkapadi/WISP
        private void bubbleUp(long index, HeapEntry <Titem> he)
        {
            long parent = getParent(index);

            // note: (index > 0) means there is a parent
            while ((index > 0) && (m_Heap[parent].Priority < he.Priority))
            {
                m_Heap[index] = m_Heap[parent];
                index         = parent;
                parent        = getParent(index);
            }
            m_Heap[index] = he;
        }
コード例 #3
0
ファイル: PriorityQueue.cs プロジェクト: Amitkapadi/WISP
        private void trickleDown(long index, HeapEntry <Titem> he)
        {
            long child = getLeftChild(index);

            while (child < m_Count)
            {
                if (((child + 1) < m_Count) &&
                    (m_Heap[child].Priority < m_Heap[child + 1].Priority))
                {
                    child++;
                }
                m_Heap[index] = m_Heap[child];
                index         = child;
                child         = getLeftChild(index);
            }
            bubbleUp(index, he);
        }