ADS
Algorithms and Data Structures
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
98namespace ADS
99{
100
127[[nodiscard]] inline std::vector< std::uint8_t >
128huffmanCompress( std::span< const std::uint8_t > in );
129
158[[nodiscard]] inline std::vector< std::uint8_t >
159huffmanDecompress( std::span< const std::uint8_t > in );
160
192[[nodiscard]] inline std::array< std::uint8_t , 256 >
193limitedHuffmanLengths( 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/*--------------------------------------------------------------------------*/
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
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
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 ,...
std::vector< std::uint8_t > huffmanDecompress(std::span< const std::uint8_t > in)
the bytes that huffmanCompress() coded in in
Definition ADT.h:96