-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlz77.h
38 lines (32 loc) · 1.23 KB
/
lz77.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
33
34
35
36
37
38
/**
* @file lz77.h
* @brief Header file for the LZ77 compression/decompression algorithm.
*/
#ifndef LZ77_LZ77_H
#define LZ77_LZ77_H
#include <vector>
#include <string>
/**
* @brief Token structure representing a single token in the LZ77 algorithm.
*/
struct Token
{
int offset; /** @brief Backward offset in the history buffer. Represents the number of characters to go back to reach the beginning of the previous sequence. */
int length_of_match; /** @brief Length of the match. */
char code_word; /** @brief Single-byte dictionary code. */
};
/**
* @brief Function performing compression using the LZ77 algorithm.
* @param input Input text to compress.
* @param searchBuffer Size of the history buffer.
* @param lookAheadBuffer Size of the look-ahead buffer.
* @return Array of Token structures representing the compressed text.
*/
std::vector<Token> compression_lz77(const std::string &input, int searchBuffer, int lookAheadBuffer);
/**
* @brief Function performing decompression using the LZ77 algorithm.
* @param compressed_data Array of Token structures representing the compressed text.
* @return Decompressed text.
*/
std::string decompression_lz77(const std::vector<Token> &compressed_data);
#endif // LZ77_LZ77_H