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

📄 extbintree.h

📁 文件压缩与解压
💻 H
字号:
# ifndef EXTTREE_CLASS
# define EXTTREE_CLASS

# include "Heap.h"

# include <map>

using namespace std;

template <class T>
class code
{
public:
	T data;
	int key;
};

template <class T>
class ExtBinTree;

template <class T>
class Element
{
	friend class ExtBinTree<T>;
public:
	Element():left(NULL),right(NULL),mark(0){}
	code<T> c;
	void SetLeft(Element<T>* l){left=l;}
	void SetRight(Element<T>* r){right=r;}
	void SetParent(Element<T>* l){parent=l;}
	Element<T>* GetLeft(){return left;}
	Element<T>* GetRight(){return right;}
	Element<T>* GetParent(){return parent;}
	int GetMark(){return mark;}
	void SetMark(int m){mark=m;}
private:
	int mark;
	Element<T>* left;
	Element<T>* right;
	Element<T>* parent;
};

template <class T>
class ExtBinTree
{
public:
	bool operator>(ExtBinTree<T>& t){return root->c.key>t.root->c.key;}
	bool operator<=(ExtBinTree<T>& t){return root->c.key<=t.root->c.key;}
	bool operator<(ExtBinTree<T>& t){return root->c.key<t.root->c.key;}
	ExtBinTree(){root=new Element<T>();}
	ExtBinTree(ExtBinTree& t1,ExtBinTree& t2)
	{
		root=new Element<T>();
		root->left=t1.root;
		root->right=t2.root;
		root->c.key=t1.root->c.key+t2.root->c.key;
		t1.root->parent=t2.root->parent=root;
	}
	Element<T>* root;
	void Disp(Element<T>* t);
protected:
	enum {DefaultSize=100};
};


# endif
	

⌨️ 快捷键说明

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