-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNode.h
More file actions
48 lines (40 loc) · 1.41 KB
/
Node.h
File metadata and controls
48 lines (40 loc) · 1.41 KB
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
//
// Created by Alen Handukic on 2019-03-18.
//To be used in conjunction with BSTree.h and BSTree.hpp
//If you modify this, please add your name and list any changes that you made
#ifndef DSFINALPROJECT_NODE_H
#define DSFINALPROJECT_NODE_H
#include <iostream>
#include <string>
#include <vector>
using namespace std;
// A tree node class for ints
//Placeholder for a composite data type
struct GeneralData
{
int number; //Update this to your data field
string name;
};
//Binary Tree Node
template <typename DATATYPE, typename KEYTYPE>
class Node {
private:
string key; //This should be the datatype of your key...sorted field in tree
DATATYPE data;
Node<DATATYPE, KEYTYPE> * left;
Node<DATATYPE, KEYTYPE> * right;
Node<DATATYPE, KEYTYPE> * parent;
public:
Node() {left=nullptr; right=nullptr; parent = nullptr;};
void setKey(KEYTYPE aKey) { key = aKey; };
void setData(DATATYPE aData) { data = aData; }
void setLeft(Node<DATATYPE, KEYTYPE> * aLeft) { left = aLeft; };
void setRight(Node<DATATYPE, KEYTYPE> * aRight) { right = aRight; };
void setParent(Node<DATATYPE, KEYTYPE> * aParent) { parent = aParent; };
KEYTYPE Key() { return key; };
DATATYPE Data() { return data; }
Node<DATATYPE, KEYTYPE> * Left() { return left; };
Node<DATATYPE, KEYTYPE> * Right() { return right; };
Node<DATATYPE, KEYTYPE> * Parent() { return parent; };
};
#endif //DSFINALPROJECT_NODE_H