-
Notifications
You must be signed in to change notification settings - Fork 0
/
tree.hpp
64 lines (50 loc) · 1.36 KB
/
tree.hpp
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
/*
* Autor: Jordan Jarolim (xjarol03)
* Datum: 16.2.2017
* Soubor: tree.hpp
* Komentar:
*/
#ifndef tree_hpp
#define tree_hpp
#include <stdio.h>
#include <vector>
#include <stdint.h>
/* Value in ROOT node */
#define ROOT -1
/* Value in NYT node */
#define NYT -2
/* Value on intersection */
#define CROSS 0
/* Init values */
#define INIT_WEIGHT 0
#define INIT_SYMBOL_WEIGHT 1
#define INIT_ORDER 512
/* directions */
#define MOVE_LEFT 1000
#define MOVE_RIGHT 1001
class Tree{
public:
int64_t val; //character in tree node
int64_t weight; //number of times val has occured in file
int64_t order; //ordering system to track weights
Tree* left;
Tree* right;
Tree* parent;
static std::vector<int64_t> _listOfUsedChars;
static bool alreadySeen(int64_t symbol);
static void printTree(Tree* p, int indent=0);
static Tree* nyt;
static Tree* root;
static unsigned short peof;
/* Constructors */
Tree(int64_t value, int64_t wei, int64_t num, Tree* l, Tree* r, Tree* p);
Tree();
/* Other methods */
void newSymbol(int64_t symbol);
void updateSymbol(int64_t symbol);
Tree* findSymbol(int64_t symbol, Tree* parent);
Tree* findFarSibling(int64_t order, Tree* parent);
void updateTree();
void getWeightClass(std::vector<Tree*> *weightClass, Tree* parent);
};
#endif /* tree_hpp */