blob: 1c00a806375146c4aac0a9004e8cd5f6602868e2 (
plain) (
blame)
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
39
|
#pragma once
#include "codecs.h"
#include <util/generic/ptr.h>
#include <util/string/cast.h>
namespace NCodecs {
// for types greater than char, pipeline with TFreqCodec.
class THuffmanCodec: public ICodec {
class TImpl;
TIntrusivePtr<TImpl> Impl;
public:
THuffmanCodec();
~THuffmanCodec() override;
static TStringBuf MyName() {
return "huffman";
}
TString GetName() const override {
return ToString(MyName());
}
ui8 Encode(TStringBuf in, TBuffer& bbb) const override;
void Decode(TStringBuf in, TBuffer& bbb) const override;
void LearnByFreqs(const TArrayRef<std::pair<char, ui64>>& freqs);
protected:
void DoLearn(ISequenceReader& in) override;
void Save(IOutputStream* out) const override;
void Load(IInputStream* in) override;
};
}
|