-
Notifications
You must be signed in to change notification settings - Fork 1
/
AVLInterface.h
47 lines (39 loc) · 1.08 KB
/
AVLInterface.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
//YOU MAY NOT MODIFY THIS DOCUMENT
/*
*/
#pragma once
#include "NodeInterface.h"
using namespace std;
class AVLInterface {
public:
AVLInterface() {}
virtual ~AVLInterface() {}
//Please note that the class that implements this interface must be made
//of objects which implement the NodeInterface
/*
* Returns the root node for this tree
*
* @return the root node for this tree.
*/
virtual NodeInterface * getRootNode() const = 0;
/*
* Attempts to add the given int to the AVL tree
* Rebalances the tree if data is successfully added
*
* @return true if added
* @return false if unsuccessful (i.e. the int is already in tree)
*/
virtual bool add(int data) = 0;
/*
* Attempts to remove the given int from the AVL tree
* Rebalances the tree if data is successfully removed
*
* @return true if successfully removed
* @return false if remove is unsuccessful(i.e. the int is not in the tree)
*/
virtual bool remove(int data) = 0;
/*
* Removes all nodes from the tree, resulting in an empty tree.
*/
virtual void clear() = 0;
};