-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHoffmanTree.h
32 lines (32 loc) · 1.12 KB
/
HoffmanTree.h
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
#pragma once
using namespace std;
#include "BST.h"
namespace Hofman
{
class HoffmanNode
{
private:
char _letter;
int _frequency;
HoffmanNode* left; HoffmanNode* right;
HoffmanNode* parent;
public:
HoffmanNode() { _letter = 0; _frequency = 0; left = nullptr; right = nullptr; parent = nullptr; };
HoffmanNode(char letter, int frequency);
~HoffmanNode() {};
HoffmanNode(const HoffmanNode& other) = delete;
HoffmanNode& operator=(const HoffmanNode& other) = delete;
HoffmanNode* getLeft() const{ return left; }
HoffmanNode* getRight() const{ return right; }
int getLeftFreq() const { return left->_frequency; }
int getRightFreq() const { return right->_frequency; }
int getFreq ()const { return _frequency; }
char getLetter()const { return _letter; }
void setFreq(const int toset) { _frequency = toset; }
void setLetter(const char toset) { _letter = toset; }
void setLeft(HoffmanNode* Left) { left = Left; Left->parent = this; }
void setRight(HoffmanNode* Right) { right = Right; Right->parent = this; };
void remove();
bool isLeaf()const;
};
}