38 template<
typename InputBuffer,
typename OutputBuffer>
42 const unsigned int symbols_count = input.symbols_count();
45 unsigned int table_size = 0;
47 unsigned int prefix = input.get_next();
49 if ( !input.end_of_data() )
51 while ( !input.end_of_data() )
53 unsigned int suffix = input.get_next();
55 if (!input.end_of_data() )
57 unsigned int new_suffix;
59 if ( suffix < table_size + symbols_count )
60 new_suffix = get_first_symbol(table, suffix, symbols_count);
62 new_suffix = get_first_symbol(table, prefix, symbols_count);
64 table.push_back( word_type(prefix, new_suffix) );
66 input.new_code(table_size + symbols_count);
68 decompose( table, prefix, symbols_count, output );
73 decompose( table, prefix, symbols_count, output );
84 template<
typename InputBuffer,
typename OutputBuffer>
86 (
const table_type& table,
const unsigned int code,
87 const unsigned int symbols_count )
const
89 unsigned int result = code;
91 while ( result >= symbols_count )
92 result = table[result - symbols_count].first;
105 template<
typename InputBuffer,
typename OutputBuffer>
107 (
const table_type& table,
unsigned int code,
108 const unsigned int symbols_count, output_buffer_type& output )
const
110 std::list<unsigned int> result;
112 while ( code >= symbols_count )
114 result.push_front( table[code - symbols_count].second );
115 code = table[code - symbols_count].first;
118 result.push_front(code);
120 std::list<unsigned int>::const_iterator it;
122 for (it=result.begin(); it!=result.end(); ++it)