ADS
Algorithms and Data Structures
Toggle main menu visibility
Loading...
Searching...
No Matches
Huffman.h
Go to the documentation of this file.
1
/*--------------------------------------------------------------------------*/
2
/*----------------------------- File Huffman.h -----------------------------*/
3
/*--------------------------------------------------------------------------*/
34
/*--------------------------------------------------------------------------*/
35
/*----------------------------- DEFINITIONS --------------------------------*/
36
/*--------------------------------------------------------------------------*/
37
38
#ifndef __ADS_Huffman
39
#define __ADS_Huffman
40
/* self-identification: #endif constant */
41
42
/*--------------------------------------------------------------------------*/
43
/*------------------------------ INCLUDES ----------------------------------*/
44
/*--------------------------------------------------------------------------*/
45
46
#include "
ADS/Contract.h
"
47
#include "
ADS/priority/HeapPriorityQueue.h
"
48
49
#include <algorithm>
50
#include <cstddef>
51
#include <map>
52
#include <stdexcept>
53
#include <string>
54
#include <vector>
55
56
/*--------------------------------------------------------------------------*/
57
/*--------------------------- NAMESPACE ------------------------------------*/
58
/*--------------------------------------------------------------------------*/
59
60
namespace
ADS
61
{
62
88
template
<
class
C ,
class
F >
89
std::map< C , std::string >
huffman
(
const
std::map< C , F > & freq );
90
93
template
<
class
C >
94
std::string
encode
(
const
std::basic_string< C > & text ,
95
const
std::map< C , std::string > & code );
96
115
template
<
class
C >
116
std::basic_string< C >
decode
(
const
std::string & bits ,
117
const
std::map< C , std::string > & code );
118
119
/*--------------------------------------------------------------------------*/
120
121
}
// end( namespace ADS )
122
123
/*--------------------------------------------------------------------------*/
124
/*-------------------------- IMPLEMENTATION --------------------------------*/
125
/*--------------------------------------------------------------------------*/
126
127
#include "ADS/string/impl/Huffman.tpp"
128
129
/*--------------------------------------------------------------------------*/
130
131
#endif
/* Huffman.h included */
132
133
/*--------------------------------------------------------------------------*/
134
/*--------------------------- End File Huffman.h ---------------------------*/
135
/*--------------------------------------------------------------------------*/
Contract.h
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
HeapPriorityQueue.h
The PRIORITYQUEUE [see PriorityQueue.h] on a heap.
ADS::encode
std::string encode(const std::basic_string< C > &text, const std::map< C, std::string > &code)
the text encoded by the codes, the code of each character in turn
ADS::decode
std::basic_string< C > decode(const std::string &bits, const std::map< C, std::string > &code)
the bits decoded by the codes, a prefix code
ADS::huffman
std::map< C, std::string > huffman(const std::map< C, F > &freq)
the codes of Huffman of the characters with the given frequencies, at least one; a single character g...
ADS
Definition
ADT.h:96
ADS
string
Huffman.h
Generated by
1.17.0