文档介绍:-
. z.
. .
T>  
Ma*Heap<T>& Ma*Heap<T>::Insert(const T& *)  
{// Insert * into the ma* heap.  
    if (CurrentSize == Ma*Size)  
    {  
        cout<<"no space!"<<endl;   
        return *this;   
    }  
    // 寻找新元素*的位置
// i——初始为新叶节点的位置,逐层向上,寻找最终位置
int i = ++CurrentSize;  
    while (i != 1 && * > heap[i/2])  
    {  
        // i不是根节点,且其值大于父节点的值,需要继续调整
heap[i] = heap[i/2]; // 父节点下降
i /= 2;              // 继续向上,搜寻正确位置
    }  
heap[i] = *;  
   return *this;  
}  
template<class T>  
. .
. 专业资料.
-
. z.
Ma*Heap<T>& Ma*Heap<T>::DeleteMa*(T& *)  
{// Set * to ma* element and delete ma* element from heap.  
    // check if heap is empty  
    if (CurrentSize == 0)  
    {  
        cout<<"Empty heap!"<<endl;   
        return *this;   
    }  
    * = heap[1]; // 删除最大元素
// 重整堆
T y = heap[CurrentSize--]; // 取最后一个节点,从根开场重整
// find place for y starting at root  
    int i = 1,  // current node of heap  
       ci = 2; // child of i  
    while (ci <= CurrentSize)   
    {  
        // 使ci指向i的两个孩子中较大者
if (ci < CurrentSize && heap[ci] < heap[ci+1])  
        {  
            ci++;  
        }  
        // y的值大于等于孩子节点吗.
. .
. 专业资料.
-
. z.
if (y >= heap[ci])  
        {  
            break;   // 是,i就是y的正确位置,退出
        }  
// 否,需要继续向下,重整堆
heap[i] = heap[ci]; // 大于父节点的孩子节点上升
i = ci;             // 向下一层,继续搜索正确位置
ci *= 2;  
    }  
    heap[i] = y;  
    return *this;  
}  
template<class T>  
void Ma*Heap<T>::Initialize(T a[], int size,int ArraySize)  
{// Initialize ma* heap to array a.  
    delete [] heap;  
    heap = a;  
    C