📄 maxheap.h
字号:
// MaxHeap.h: interface for the CMaxHeap class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_MAXHEAP_H__9AE26F27_C1DC_4631_B002_6453FF4CD981__INCLUDED_)
#define AFX_MAXHEAP_H__9AE26F27_C1DC_4631_B002_6453FF4CD981__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "heapsort.h"
class CMaxHeap
{
int * Heap;
int n;
CHeapSort* MyOwner;
int siftdown(int p);
public:
CMaxHeap(int *,int num,CHeapSort* owner);
virtual ~CMaxHeap();
int heapsize() const {return n;}
int isLeaf(int p) const
{return (p>=n/2)&&(p<n);}
int leftChild(int p) const
{return 2*p+1;}
int rightChild(int p) const
{return 2*p+2;}
int parent(int p) const
{return (p-1)/2;}
int removemax();
void buildHeap()
{for (int i=n/2-1;i>=0;i--) siftdown(i);}
};
#endif // !defined(AFX_MAXHEAP_H__9AE26F27_C1DC_4631_B002_6453FF4CD981__INCLUDED_)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -