-
Notifications
You must be signed in to change notification settings - Fork 0
/
chartree.hh
70 lines (48 loc) · 1.23 KB
/
chartree.hh
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
58
59
60
61
62
63
64
65
66
67
68
69
70
#ifndef CHARTREE_HH_
#define CHARTREE_HH_
/*
Struct that holds the data of the tree
*/
struct Node
{
bool is_char;
char c;
Node *previous, *right, *left;
};
/*
This class forms the character tree that will be used to encript the
characters.
*/
class CharTree
{
public:
// default constructor, should not be used
CharTree();
// chaaracter node constructor
CharTree (char c);
// non character node constructor
CharTree (CharTree& left, CharTree& right);
// move node pointer to the right
void ptrRight ();
// move node pointer to the left
void ptrLeft ();
// move node pointer to the previous note
void ptrBack ();
// move the node pointer back to the root node
void ptrToRoot ();
// tells if the node pointed by the node pointer is a character
bool isChar ();
// if the node pointed by the node pointer is a char, it's value is returned
char getChar ();
// when the non character constructor is used, the node is removed. This
// function tells if the current tree has a node
bool hasRoot ();
// returns whether the node pointer is at the root
bool ptrAtRoot ();
private:
Node* node_ptr;
Node* root;
// clear the root pointer adn node pointer
void deleteRootNode ();
};
#endif