11#include <string/LinearString.h>
17namespace compression {
21 template <
class SymbolType >
25 template <
class SymbolType >
30template <
class SymbolType >
33 if(searchBufferSize == 0)
36 if(lookaheadBufferSize == 0)
41 std::vector < std::tuple < unsigned, unsigned, SymbolType > > output;
43 while ( pointer <
string.getContent ( ).size ( ) ) {
44 unsigned lookaheadBufferRealSize = lookaheadBufferSize;
45 if ( pointer + lookaheadBufferSize + 1 >
string.getContent ( ).size ( ) )
46 lookaheadBufferRealSize =
string.getContent ( ).size ( ) - pointer - 1;
48 unsigned searchBufferRealSize = searchBufferSize;
49 if ( pointer < searchBufferSize )
50 searchBufferRealSize = pointer;
52 unsigned maxMatch = 0;
53 unsigned sbPointer = pointer;
54 for (
unsigned j = pointer - searchBufferRealSize; j < pointer; j ++ ) {
55 unsigned match = equal (
string, pointer, pointer + lookaheadBufferRealSize, j );
57 if ( maxMatch <= match ) {
63 output.push_back ( std::tuple < unsigned, unsigned, SymbolType > ( pointer - sbPointer, maxMatch,
string.getContent ( ) [ pointer + maxMatch ] ) );
64 pointer = pointer + maxMatch + 1;
71template <
class SymbolType >
76 while ( first1 < last1 ) {
77 if (
string.getContent ( )[first1] !=
string.getContent ( )[first2] )
Basic exception from which all other exceptions are derived.
Definition: CommonException.h:21
Linear string.
Definition: LinearString.h:57
Definition: LZ77Compression.h:19
static std::vector< std::tuple< unsigned, unsigned, SymbolType > > compress(const string::LinearString< SymbolType > &string, unsigned searchBufferSize, unsigned lookaheadBufferSize)
Definition: LZ77Compression.h:31
Definition: ArithmeticCompression.h:18