maxbheap.h

来自「MaxHeap operation like insert and delete」· C头文件 代码 · 共 46 行

H
46
字号
#ifndef MAXBHEAP_H
#define MAXBHEAP_H

#include <iostream>

using namespace std;

template <class DType>
class MaxBHeap
{
public:
	enum {MaxElement =100};
	MaxBHeap(unsigned int size=MaxElement);
	MaxBHeap(const MaxBHeap& maxBHeap);
	MaxBHeap& operator = (const MaxBHeap& maxBHeap);
	~MaxBHeap();

	void Build(DType* obj, unsigned int size);

	void Insert(const DType& obj);
	DType DeleteMax();

	bool IncKey(unsigned int pos, const DType& obj);
	bool DecKey(unsigned int pos, const DType& obj);

	template <class DType>
	friend ostream& operator << (ostream& os, const MaxBHeap<DType>& maxBHeap);
protected:
	void percolatedown(unsigned int pos);
	bool IsFull();
	bool IsEmpty();


private:
	unsigned int maxkeys;
	unsigned int numkeys;
	DType* Keys;



};

#include "MaxBHeapcpp.h"


#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?