-
Notifications
You must be signed in to change notification settings - Fork 1
/
bst.h
138 lines (117 loc) · 4.38 KB
/
bst.h
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#include "chocan.h"
class provider_node
{
public:
provider_node();
~provider_node();
provider_node(provider *& copy);
provider_node *& go_left(); //returns left pointer
provider_node *& go_right(); //returns right pointer
void display(); //calls provider's display function
provider* retrieve_provider_data();
//wrappers for operator overloading
bool greater(provider *& compare);
bool greater(int compare);
bool equal(int compare);
private:
provider * provider_data;
provider_node * left;
provider_node * right;
};
class BST_provider
{
public:
BST_provider();
~BST_provider();
//BST_provider(BST_provider & copy); //copy constructor
//add and remove functions
void add_new_provider_(provider *& to_add); // add by an object
bool remove_provider_(int ID);
bool display_by_ID(int ID);
bool search_by_ID(int ID);
provider* retrieve_provider(int ID);
int count_nodes();
void display_tree_();
private:
//recursive functions
void add_provider(provider *& to_add, provider_node *& root);
bool remove_provider(int ID, provider_node *& root);
bool display_ID(int ID, provider_node *& root);
bool search_ID(int ID, provider_node *& root);
provider* retrieve_provider(int ID, provider_node *& root);
int count_nodes(provider_node * root);
void display_tree(provider_node * root);
void delete_all(provider_node *& root); //for destructor
void find_ios(provider_node *& root, provider_node *& ios); //less headache when removing via match
provider_node * root;
};
class member_node
{
public:
member_node();
~member_node();
member_node(member *& copy);
member_node *& go_left(); //returns left pointer
member_node *& go_right(); //returns right pointer
void display(); //calls member's display function
member* retrieve_member_data();
bool greater(member *& compare);
bool greater(int compare);
bool equal(int compare);
private:
member * member_data;
member_node * left;
member_node * right;
};
class BST_member
{
public:
BST_member();
~BST_member();
//BST_member(BST_member & copy); //copy constructor
//add and remove functions
void add_new_member_(member *& to_add); // add by an object
bool remove_member_(int ID);
bool display_by_ID(int ID);
bool search_by_ID(int ID);
member* retrieve_member(int ID);
void display_tree_();
private:
//recursive functions
void add_member(member *& to_add, member_node *& root);
bool remove_member(int ID, member_node *& root);
bool display_ID(int ID, member_node *& root);
bool search_ID(int ID, member_node *& root);
member* retrieve_member(int ID, member_node *& root);
void display_tree(member_node * root);
void delete_all(member_node *& root); //for destructor
void find_ios(member_node *& root, member_node *& ios); //less headache when removing via match
member_node * root;
};
class manager
{
public:
manager();
manager(const manager & copy); //copy constructor, if needed
~manager();
//add members or providers
void add_provider(BST_provider *&);
void add_member(BST_member *&);
//remove members or providers, based on ID
bool remove_provider(BST_provider *&);
bool remove_member(BST_member *&);
//display a info of an invidual by ID
bool search_display_provider(BST_provider *&);
bool search_display_member(BST_member *&);
// display a whole list of ...
void display_provider(BST_provider *) const;
void display_member(BST_member *) const;
void read() const;
void update_info();
void retrieve();
void write_report(); //writing EFT data to disk
private:
int manager_ID;
BST_provider * manage_p;
BST_member * manage_m;
};