-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaccounttree.h
50 lines (39 loc) · 1.08 KB
/
accounttree.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
#ifndef ASS5_ACCOUNTTREE_H
#define ASS5_ACCOUNTTREE_H
#include "account.h"
#include <iostream>
class AccountTree {
public:
// Create BST
AccountTree();
// Delete all nodes in BST
~AccountTree();
// Insert new account
bool insert(Account *Account);
// Retrieve account
// returns true if successful AND *Acc points to account
bool retrieve(const int &AccountNumber, Account *&Account) const;
// Display information on all accounts
void display() const;
// delete all information in AccountTree
void clear();
// check if tree is empty
bool isEmpty() const;
private:
struct Node {
public:
explicit Node(Account *A)
: Acc{A}, Right{nullptr}, Left{nullptr} {};
Account* Acc;
Node* Right;
Node* Left;
};
Node *Root = nullptr;
//display nodes using inorder traversal
void displayNodes(Node* N) const;
//deletes nodes and the accounts within them
static void deleteNodes(Node* N);
//finds a node given a parent and account number
Node * findNode(Node* Parent, const int &AccountNum) const;
};
#endif // ASS5_ACCOUNTTREE_H