-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArcoderModel.h
More file actions
52 lines (38 loc) · 1.19 KB
/
ArcoderModel.h
File metadata and controls
52 lines (38 loc) · 1.19 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
#ifndef ARCODERMODEL_H
#define ARCODERMODEL_H
#include <vector>
#include <map>
#include <set>
#include <limits.h>
class ArcoderModel
{
static const int kNewSymbolCode = INT_MAX;
static const int kEOFSymbolCode = kNewSymbolCode - 1;
std::vector<int> m_cumulativeFreqs;
std::vector<int> m_freqs;
std::map<int, int> m_symbolToIndex;
std::map<int, int> m_indexToSymbol;
std::set<int> m_symbols;
unsigned int m_lastIndex;
void Reset();
void AddSymbol(int i_symbol, int i_usageCount = 1);
public:
ArcoderModel();
~ArcoderModel() {}
void InitUniformModel(int i_symbolCount);
void Update(int i_symbol);
void CalculateBounds(int i_symbol,
unsigned long& io_lowerBound,
unsigned long& io_upperBound) const;
int GetSymbol(unsigned long i_value,
unsigned long& io_lowerBound,
unsigned long& io_upperBound) const;
int NewSymbolCode() const;
int EOFSymbolCode() const;
bool SymbolExists(int) const;
void Load(const std::vector<int>& i_symbols,
const std::vector<int>& i_freqs);
void Save(std::vector<int>& o_symbols,
std::vector<int>& o_freqs);
};
#endif // ARCODERMODEL_H