-
Notifications
You must be signed in to change notification settings - Fork 0
/
TreeDB.h
57 lines (43 loc) · 1.69 KB
/
TreeDB.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
#ifndef _TREEDB_H
#define _TREEDB_H
#include "TreeNode.h"
#include "DBentry.h"
#include <iostream>
class TreeDB {
private:
TreeNode* root;
int probesCount;
// You will need to add additional private functions
public:
// the default constructor, creates an empty database.
TreeDB();
// the destructor, deletes all the entries in the database.
~TreeDB();
// inserts the entry pointed to by newEntry into the database.
// If an entry with the same key as newEntry's exists
// in the database, it returns false. Otherwise, it returns true.
bool insert(DBentry* newEntry);
// searches the database for an entry with a key equal to name.
// If the entry is found, a pointer to it is returned.
// If the entry is not found, the NULL pointer is returned.
// Also sets probesCount
DBentry* find(string name);
// deletes the entry with the specified name (key) from the database.
// If the entry was indeed in the database, it returns true.
// Returns false otherwise.
// See section 6 of the lab handout for the *required* removal method.
// If you do not use that removal method (replace deleted node by
// maximum node in the left subtree when the deleted node has two children)
// you will not match exercise's output.
bool remove(string name);
// deletes all the entries in the database.
void clear();
// prints the number of probes stored in probesCount
void printProbes() const;
// computes and prints out the total number of active entries
// in the database (i.e. entries with active==true).
void countActive () const;
// Prints the entire tree, in ascending order of key/name
void print();
};
#endif