GenericVector -> std::vector.

This commit is contained in:
Egor Pugin 2021-03-03 22:22:00 +03:00
parent 0a693a9519
commit c39b1daa6b
2 changed files with 8 additions and 8 deletions

View File

@ -214,7 +214,7 @@ bool UnicharCompress::ComputeEncoding(const UNICHARSET& unicharset, int null_id,
// Sets up an encoder that doesn't change the unichars at all, so it just
// passes them through unchanged.
void UnicharCompress::SetupPassThrough(const UNICHARSET& unicharset) {
GenericVector<RecodedCharID> codes;
std::vector<RecodedCharID> codes;
for (int u = 0; u < unicharset.size(); ++u) {
RecodedCharID code;
code.Set(0, u);
@ -230,7 +230,7 @@ void UnicharCompress::SetupPassThrough(const UNICHARSET& unicharset) {
// Sets up an encoder directly using the given encoding vector, which maps
// unichar_ids to the given codes.
void UnicharCompress::SetupDirect(const GenericVector<RecodedCharID>& codes) {
void UnicharCompress::SetupDirect(const std::vector<RecodedCharID>& codes) {
encoder_ = codes;
ComputeCodeRange();
SetupDecoder();
@ -298,12 +298,13 @@ int UnicharCompress::DecodeUnichar(const RecodedCharID& code) const {
// Writes to the given file. Returns false in case of error.
bool UnicharCompress::Serialize(TFile* fp) const {
return encoder_.SerializeClasses(fp);
return fp->SerializeClasses(encoder_);
}
// Reads from the given file. Returns false in case of error.
bool UnicharCompress::DeSerialize(TFile* fp) {
if (!encoder_.DeSerializeClasses(fp)) return false;
if (!fp->DeSerializeClasses(encoder_))
return false;
ComputeCodeRange();
SetupDecoder();
return true;

View File

@ -153,7 +153,7 @@ class TESS_API UnicharCompress {
void SetupPassThrough(const UNICHARSET& unicharset);
// Sets up an encoder directly using the given encoding vector, which maps
// unichar_ids to the given codes.
void SetupDirect(const GenericVector<RecodedCharID>& codes);
void SetupDirect(const std::vector<RecodedCharID>& codes);
// Returns the number of different values that can be used in a code, ie
// 1 + the maximum value that will ever be used by an RecodedCharID code in
@ -214,10 +214,9 @@ class TESS_API UnicharCompress {
// The encoder that maps a unichar-id to a sequence of small codes.
// encoder_ is the only part that is serialized. The rest is computed on load.
GenericVector<RecodedCharID> encoder_;
std::vector<RecodedCharID> encoder_;
// Decoder converts the output of encoder back to a unichar-id.
std::unordered_map<RecodedCharID, int, RecodedCharID::RecodedCharIDHash>
decoder_;
std::unordered_map<RecodedCharID, int, RecodedCharID::RecodedCharIDHash> decoder_;
// True if the index is a valid single or start code.
GenericVector<bool> is_valid_start_;
// Maps a prefix code to a list of valid next codes.