Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
LZ77Decompression.h
Go to the documentation of this file.
1
6#pragma once
7
8#include <tuple>
9#include <vector>
10#include <alib/set>
11
12#include <string/LinearString.h>
13
14namespace stringology {
15
16namespace compression {
17
19public:
20 template < class SymbolType >
21 static string::LinearString < SymbolType > decompress ( const std::vector < std::tuple < unsigned, unsigned, SymbolType > > & input );
22};
23
24// Main method that handle decompress
25template < class SymbolType >
26string::LinearString < SymbolType > LZ77Decompression::decompress ( const std::vector < std::tuple < unsigned, unsigned, SymbolType > > & input ) {
27
29
30 for ( unsigned i = 0; i < input.size ( ); i++ ) {
31 for ( unsigned j = 0; j < std::get < 1 > ( input[i] ); j++ ) {
32 output.appendSymbol ( output.getContent ( )[output.getContent ( ).size ( ) - std::get < 0 > ( input[i] )] );
33 }
34
35 output.extendAlphabet ( ext::set < SymbolType > { std::get < 2 > ( input[i] ) } );
36 output.appendSymbol ( std::get < 2 > ( input[i] ) );
37 }
38
39 return output;
40}
41
42} /* namespace compression */
43
44} /* namespace stringology */
45
Definition: set.hpp:44
Linear string.
Definition: LinearString.h:57
const ext::vector< SymbolType > & getContent() const &
Definition: LinearString.h:238
void appendSymbol(SymbolType symbol)
Definition: LinearString.h:230
void extendAlphabet(const ext::set< SymbolType > &symbols)
Definition: LinearString.h:121
Definition: LZ77Decompression.h:18
static string::LinearString< SymbolType > decompress(const std::vector< std::tuple< unsigned, unsigned, SymbolType > > &input)
Definition: LZ77Decompression.h:26
int i
Definition: AllEpsilonClosure.h:118
Definition: ArithmeticCompression.h:18