树  0.1
数据结构_第6章
binTree.h
Go to the documentation of this file.
1 /****************************************************
2  * @file binTree.h
3  * @author Guorui Wei (313017602@qq.com)
4  * @brief 二叉树的抽象类
5  * @version 0.1
6  * @date 2020-04-19
7  *
8  * @copyright Copyright (c) 2020
9  *
10  * See the file LICENSE in the top directory of this distribution for
11  * more information.
12  *
13  ****************************************************/
14 
15 #ifndef __BIN_TREE_H__
16 #define __BIN_TREE_H__
17 
18 namespace Tree
19 {
20 
21 template <typename T>
22 class binTree
23 {
24 public:
29  typedef T value_type;
30  typedef value_type &reference;
31  typedef const value_type &const_reference;
32  typedef size_t size_type;
33 
34 public:
35  virtual void clear() = 0;
36  virtual bool empty() const = 0;
37  virtual value_type root(value_type flag) const = 0;
38  virtual value_type parent(value_type x, value_type flag) const = 0;
39  virtual value_type lchild(value_type x, value_type flag) const = 0;
40  virtual value_type rchild(value_type x, value_type flag) const = 0;
41  virtual void delLeft(value_type x) = 0;
42  virtual void delRight(value_type x) = 0;
43  virtual void preOrder() const = 0;
44  virtual void inOrder() const = 0;
45  virtual void postOrder() const = 0;
46  virtual void levelOrder() const = 0;
47 };
48 
49 } // namespace Tree
50 
51 #endif // __BIN_TREE_H__
Tree::binTree::preOrder
virtual void preOrder() const =0
Tree::binTree::parent
virtual value_type parent(value_type x, value_type flag) const =0
Tree::binTree::root
virtual value_type root(value_type flag) const =0
Tree::binTree::delRight
virtual void delRight(value_type x)=0
Tree::binTree::postOrder
virtual void postOrder() const =0
Tree::binTree::levelOrder
virtual void levelOrder() const =0
Tree::binTree::delLeft
virtual void delLeft(value_type x)=0
Tree::binTree::empty
virtual bool empty() const =0
Tree::binTree::value_type
T value_type
类型别名定义
Definition: binTree.h:53
Tree
自定义的树类都在Tree名字空间内
Definition: binaryTree.hh:27
Tree::binTree::inOrder
virtual void inOrder() const =0
Tree::binTree::rchild
virtual value_type rchild(value_type x, value_type flag) const =0
Tree::binTree::reference
value_type & reference
数据的引用
Definition: binTree.h:54
Tree::binTree::lchild
virtual value_type lchild(value_type x, value_type flag) const =0
Tree::binTree::size_type
size_t size_type
计数器类型
Definition: binTree.h:56
Tree::binTree::const_reference
const typedef value_type & const_reference
数据的常量引用
Definition: binTree.h:55
Tree::binTree::clear
virtual void clear()=0