diff options
author | aprudaev <aprudaev@yandex-team.ru> | 2022-02-10 16:49:58 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:49:58 +0300 |
commit | 29e66fe2ab37743577f88e6ab770defc4e6c1002 (patch) | |
tree | 332323481b37f79cf521451582f724fb13a7143a /library/cpp/codecs/huffman_codec.cpp | |
parent | 66f1a2f0600877a21fcc76f83c52904a58425f78 (diff) | |
download | ydb-29e66fe2ab37743577f88e6ab770defc4e6c1002.tar.gz |
Restoring authorship annotation for <aprudaev@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/codecs/huffman_codec.cpp')
-rw-r--r-- | library/cpp/codecs/huffman_codec.cpp | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/library/cpp/codecs/huffman_codec.cpp b/library/cpp/codecs/huffman_codec.cpp index 650fe7cdfd..8882615aaf 100644 --- a/library/cpp/codecs/huffman_codec.cpp +++ b/library/cpp/codecs/huffman_codec.cpp @@ -58,15 +58,15 @@ namespace NCodecs { tree.back().Char = i; tree.back().Freq = freqs[i]; } - + StableSort(tree.begin(), tree.end(), TTreeEntry::ByFreq); - } - + } + void InitTree(TCodeTree& tree, ISequenceReader* in) { using namespace NPrivate; ui64 freqs[256]; Zero(freqs); - + TStringBuf r; while (in->NextRegion(r)) { for (ui64 i = 0; i < r.size(); ++i) @@ -466,24 +466,24 @@ namespace NCodecs { ui64 freqsArray[256]; Zero(freqsArray); - + for (const auto& freq : freqs) freqsArray[static_cast<ui8>(freq.first)] += freq.second; - + InitTreeByFreqs(tree, freqsArray); CalculateCodeLengths(tree); - + Y_ENSURE(!tree.empty(), " "); - + GenerateEncoder(tree); BuildDecoder(); } - + void Save(IOutputStream* out) { ::Save(out, Invalid.CodeLength); Encoder.Save(out); } - + void Load(IInputStream* in) { ::Load(in, Invalid.CodeLength); Encoder.Load(in); @@ -589,4 +589,4 @@ namespace NCodecs { Trained = true; } -} +} |