-
Notifications
You must be signed in to change notification settings - Fork 1
/
RangeBST.h
55 lines (44 loc) · 1.27 KB
/
RangeBST.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
#pragma once
// Forward declarations
class RangeBSTNode;
class RangeBST;
class RangeBSTNode {
public:
RangeBST* rangeBST;
RangeBSTNode* parentNode;
RangeBSTNode* leftNode;
RangeBSTNode* rightNode;
Range<unsigned int> data;
RangeBSTNode(const Range<unsigned int>& data);
~RangeBSTNode();
// Functions
RangeBSTNode* getLeastNode();
RangeBSTNode* getGreatestNode();
RangeBSTNode* getRootNode();
};
class RangeBST {
private:
RangeBSTNode* rootNode;
unsigned int size;
public:
RangeBST();
~RangeBST();
// Getters
RangeBSTNode* getRootNode() const;
unsigned int getSize() const;
RangeBSTNode* getNodeWithData(unsigned int data) const;
RangeBSTNode* getNodeWithRange(const Range<unsigned int>& range) const;
RangeBSTNode* getLeast() const;
RangeBSTNode* getGreatest() const;
// Functions
RangeBSTNode* add(unsigned int data);
RangeBSTNode* add(const Range<unsigned int>& range);
bool remove(unsigned int data);
bool remove(const Range<unsigned int>& range);
bool remove(RangeBSTNode* node);
bool contains(unsigned int data) const;
bool contains(const Range<unsigned int>& range) const;
bool contains(RangeBSTNode* node) const;
bool isEmpty() const;
void clear();
};