⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 maxbheap.h

📁 MaxHeap operation like insert and delete
💻 H
字号:
#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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -