tree.h

来自「《Visual C++ Bible》或者说是《Visual C++ 宝典》的对应」· C头文件 代码 · 共 40 行

H
40
字号
///////////////////////////////////////////////////////////////////////
//
// Tree.h - contains definitions of the base "Tree" structure.
//
// @(#)$Header:$
//
// Description:
//		This file contains the base type and information for the bare
//		sorting and searching routines in the Tree module.  It needs
//		to be augmented to do anything that is actually useful.
//
///////////////////////////////////////////////////////////////////////

class Tree;

class Node {
	protected:
		Node *left;
		Node *right;
	private:
		void balance();
		void list(int depth);
	public:
		Node();
		virtual int is_greater(Node *t)	= 0;
		virtual int is_equal(Node *t)	= 0;
		virtual void print()			= 0;
		friend Tree;
};

class Tree {
	protected:
		Node *root;
	public:
		Tree();
		Node *insert(Node *x);
		Node *search(Node *x);
		void list();
};

⌨️ 快捷键说明

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