-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTreeNode.h
More file actions
57 lines (49 loc) · 901 Bytes
/
TreeNode.h
File metadata and controls
57 lines (49 loc) · 901 Bytes
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
//Ewan Shen
//2396486
//ewshen@chapman.edu
//Michael Smith
//2396546
//michsmith@chapman.edu
//CPSC-350-01
//PA5
//details the tree node
//tree nodes are interconnected in BSTs and specifically the Scapegoat tree in this project
#ifndef TREE_NODE_H
#define TREE_NODE_H
#include <cstdlib>
#include <iostream>
template <typename T>
class TreeNode{
public:
TreeNode(T d);
virtual ~TreeNode();
T getData();
template <typename S>
friend class BST;
template <typename R>
friend class ScapegoatST;
private:
T m_data;
TreeNode<T>* m_left;
TreeNode<T>* m_right;
};
template <typename T>
TreeNode<T>::TreeNode(T d){
m_data = d;
m_left = NULL;
m_right = NULL;
}
template <typename T>
TreeNode<T>::~TreeNode(){
if(m_left != NULL){
delete m_left;
}
if(m_right != NULL){
delete m_right;
}
}
template <typename T>
T TreeNode<T>::getData(){
return m_data;
}
#endif