-
Notifications
You must be signed in to change notification settings - Fork 0
/
Node.hpp
29 lines (26 loc) · 824 Bytes
/
Node.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
#pragma once
#include <cstdint>
#include <string>
class Node{
uint8_t data;
int frequency;
std::string encoded_data;
int compare(const Node &) const;
public:
Node * left;
Node * right;
Node * internal_node;
Node();
Node(const uint8_t &d, const int &f);
Node(const Node &);
Node operator + (Node &);
int get_frequency() const {return frequency;}
uint8_t get_data() const {return data;}
void encode(const std::string &s) {encoded_data = s;}
std::string get_encoded_data() {return encoded_data;}
bool operator < (const Node & r) {return(compare(r)<0);}
bool operator > (const Node & r) {return(compare(r)>0);}
bool operator <= (const Node & r) {return(compare(r)<=0);}
bool operator >= (const Node & r) {return(compare(r)>=0);}
bool operator == (const Node & r) {return(!compare(r));}
};