-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtree.h
More file actions
68 lines (39 loc) · 1.21 KB
/
Copy pathtree.h
File metadata and controls
68 lines (39 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#ifndef TREE_H
#define TREE_H
#define DATA_type char
typedef struct TreeNode_s TreeNode_t;
typedef struct TreeNode_s* TreeNode_p_t;
typedef enum TRAVEL_type_e {
TRAVEL_R_PRE_ORDER =0,
TRAVEL_R_IN_ORDER ,
TRAVEL_R_POST_ORDER,
TRAVEL_G_PRE_ORDER,
TRAVEL_G_IN_ORDER ,
TRAVEL_G_POST_ORDER,
TRAVEL_L_PRE_ORDER,
TRAVEL_L_IN_ORDER ,
TRAVEL_L_POST_ORDER
}TRAVEL_type_t;
typedef enum ITERATOR_type_e {
ITERATOR_PRE_ORDER =0,
ITERATOR_IN_ORDER ,
ITERATOR_POST_ORDER,
ITERATOR_PRE_ORDER_LAZY,
ITERATOR_IN_ORDER_LAZY,
ITERATOR_POST_ORDER_LAZY
}ITERATOR_type_t;
class Iterator {
protected:
virtual ~Iterator() {}
public:
virtual TreeNode_p_t next() = 0;
static Iterator* AskIterator(ITERATOR_type_t type, TreeNode_p_t root);
static void Release(Iterator*);
};
typedef void (*funcVisitor) ( TreeNode_p_t node);
typedef void (*funcTravel) ( TreeNode_p_t root, funcVisitor fn);
extern void TREE_traverse(TRAVEL_type_t mode, TreeNode_p_t root, funcVisitor fn);
extern void TREE_constuct( TreeNode_p_t &theTree, TreeNode_p_t parentTree, char* &theKeyWds);
extern void TREE_destroy(TreeNode_p_t *root);
extern void TREE_get_node_value( TreeNode_p_t &theTree, const void** data );
#endif