-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNode.h
More file actions
47 lines (40 loc) · 1.12 KB
/
Node.h
File metadata and controls
47 lines (40 loc) · 1.12 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
#ifndef __NODE_H__
#define __NODE_H__
#include <iostream>
using namespace std;
class Node {
// protected:
private:
string key;
Node *leftSubtree;
Node *rightSubtree;
Node *parent;
int count;
int height;
public:
// TODO Is the ; needed (or good practice)
// after the inline default constructor?
// Node() : key(""), leftSubtree(0), rightSubtree(0), count(0) {}
Node(string key) : key(key), leftSubtree(0), rightSubtree(0), parent(0), count(1), height(0) {};
/* Accessors */
string getKey() const;
int getCount() const;
Node* getLeft() const;
Node* getRight() const;
int getHeight() const;
/* Mutators */
void copyFrom(Node *);
void incrementCount();
void decrementCount();
void setLeft(Node*);
void setRight(Node*);
void deleteLeft();
void deleteRight();
void incrementHeight();
void setParent(Node*);
/* Comparators */
bool operator==(const Node &);
/* Printing */
friend ostream& operator<<(ostream &, const Node &);
};
#endif // __NODE_H__