Skip to content

Commit

Permalink
refactor comments and variables to english
Browse files Browse the repository at this point in the history
  • Loading branch information
ViniciusMarchi committed Nov 14, 2022
1 parent cb4ecaa commit f1a1095
Show file tree
Hide file tree
Showing 8 changed files with 293 additions and 294 deletions.
56 changes: 28 additions & 28 deletions headers/huffman.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,35 @@
* After creation, the Huffman Structure are used to encode and decode a text.
*/
class Huffman {
private:
No* root; // Node that stores the root of Huffman Structure
string encodedString;
string decodedString;
float compressionRatio;
private:
Node* root; // Node that stores the root of Huffman Structure
string encodedString;
string decodedString;
float compressionRatio;

public:
Huffman(string);
~Huffman();
// Build the structure
No* buildHuffman(unordered_map<char, int>);
unordered_map<char, int> contaFrequencia(string);
public:
Huffman(string);
~Huffman();

// Build the structure
Node* buildHuffman(unordered_map<char, int>);
unordered_map<char, int> frequencyCount(string);

// Encode string
string encodeString(string);
void createHuffmanTable(No*, string, unordered_map<char, string>&);
// Decode string
string decodeString(string);
// Compute compression ratio
float computeCompressionRatio(string, string);
bool isLeaf(No*);
void deleteHuffman(No*);
// Encode string
string encodeString(string);
void createHuffmanTable(Node*, string, unordered_map<char, string>&);

// Decode string
string decodeString(string);

// Compute compression ratio
float computeCompressionRatio(string, string);

bool isLeaf(Node*);
void deleteHuffman(Node*);

// getters
string getEncodedString();
string getDecodedString();
float getCompressionRatio();
// getters
string getEncodedString();
string getDecodedString();
float getCompressionRatio();
};
41 changes: 20 additions & 21 deletions headers/minHeap.h
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
#include "no.h"
#include "node.h"
#include <unordered_map>
using namespace std;

class MinHeap{
private:
int elementsQty; // current size (number of elements)
int max; // max size
No** pointerArr; // array of pointers of Node type
private:
int elementsQty; // current size (number of elements)
int max; // max size
Node** pointerArr; // array of pointers of Node type

public:
public:
/*
* Build a heap receiving the size, the text and the map structure that stores
* occurrence frequency of each character in text
*/
MinHeap(unordered_map<char, int>);

// Due dinamic array alocation, exists a destructor to desalocate memory
~MinHeap();

/*
* Build a heap receiving the size, the text and the map structure that stores
* occurrence frequency of each character in text
*/
MinHeap(unordered_map<char, int>);

// Due dinamic array alocation, exists a destructor to desalocate memory
~MinHeap();

void goUp(int);
void goDown(int);
void buildHeap();
void insert(No*);
No* removeMin();
bool isLeaf(No*);
void goUp(int);
void goDown(int);
void buildHeap();
void insert(Node*);
Node* removeMin();
bool isLeaf(Node*);
};
24 changes: 0 additions & 24 deletions headers/no.h

This file was deleted.

24 changes: 24 additions & 0 deletions headers/node.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Definition of Node strucutre used in MinHeap and Huffman tree structures.
class Node {
private:
char info; // character
int freq; // character frequency
Node* left;
Node* right;

public:
Node(char, int);
Node();

// setters
void setInfo(char);
void setFreq(int);
void setLeft(Node*);
void setRight(Node*);

// getters
char getInfo();
int getFreq();
Node* getLeft();
Node* getRight();
};
Loading

0 comments on commit f1a1095

Please sign in to comment.