ADS
Algorithms and Data Structures
Toggle main menu visibility
Loading...
Searching...
No Matches
HuffmanCoder.h
Go to the documentation of this file.
1
/*--------------------------------------------------------------------------*/
2
/*-------------------------- File HuffmanCoder.h ---------------------------*/
3
/*--------------------------------------------------------------------------*/
71
/*--------------------------------------------------------------------------*/
72
/*----------------------------- DEFINITIONS --------------------------------*/
73
/*--------------------------------------------------------------------------*/
74
75
#ifndef __ADS_HuffmanCoder
76
#define __ADS_HuffmanCoder
77
/* self-identification: #endif constant */
78
79
/*--------------------------------------------------------------------------*/
80
/*------------------------------ INCLUDES ----------------------------------*/
81
/*--------------------------------------------------------------------------*/
82
83
#include "
ADS/Contract.h
"
84
85
#include <algorithm>
86
#include <array>
87
#include <bit>
88
#include <cstddef>
89
#include <cstdint>
90
#include <cstring>
91
#include <span>
92
#include <vector>
93
94
/*--------------------------------------------------------------------------*/
95
/*--------------------------- NAMESPACE ------------------------------------*/
96
/*--------------------------------------------------------------------------*/
97
98
namespace
ADS
99
{
100
127
[[nodiscard]]
inline
std::vector< std::uint8_t >
128
huffmanCompress
( std::span< const std::uint8_t > in );
129
158
[[nodiscard]]
inline
std::vector< std::uint8_t >
159
huffmanDecompress
( std::span< const std::uint8_t > in );
160
192
[[nodiscard]]
inline
std::array< std::uint8_t , 256 >
193
limitedHuffmanLengths
(
const
std::array< std::uint64_t , 256 > & f ,
int
L );
194
195
/*--------------------------------------------------------------------------*/
196
197
}
// end( namespace ADS )
198
199
/*--------------------------------------------------------------------------*/
200
/*-------------------------- IMPLEMENTATION --------------------------------*/
201
/*--------------------------------------------------------------------------*/
202
203
#include "ADS/compression/impl/HuffmanCoder.tpp"
204
205
/*--------------------------------------------------------------------------*/
206
207
#endif
/* HuffmanCoder.h included */
208
209
/*--------------------------------------------------------------------------*/
210
/*------------------------ End File HuffmanCoder.h -------------------------*/
211
/*--------------------------------------------------------------------------*/
Contract.h
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
ADS::huffmanCompress
std::vector< std::uint8_t > huffmanCompress(std::span< const std::uint8_t > in)
the code of Huffman of the bytes of in, with the lengths and the size
ADS::limitedHuffmanLengths
std::array< std::uint8_t, 256 > limitedHuffmanLengths(const std::array< std::uint64_t, 256 > &f, int L)
the optimal lengths of at most bits of the codes of the 256 bytes of frequencies ,...
ADS::huffmanDecompress
std::vector< std::uint8_t > huffmanDecompress(std::span< const std::uint8_t > in)
the bytes that huffmanCompress() coded in in
ADS
Definition
ADT.h:96
ADS
compression
HuffmanCoder.h
Generated by
1.17.0