mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2025-01-22 09:53:03 +08:00
GenericVector -> std::vector.
This commit is contained in:
parent
0a693a9519
commit
c39b1daa6b
@ -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
|
// Sets up an encoder that doesn't change the unichars at all, so it just
|
||||||
// passes them through unchanged.
|
// passes them through unchanged.
|
||||||
void UnicharCompress::SetupPassThrough(const UNICHARSET& unicharset) {
|
void UnicharCompress::SetupPassThrough(const UNICHARSET& unicharset) {
|
||||||
GenericVector<RecodedCharID> codes;
|
std::vector<RecodedCharID> codes;
|
||||||
for (int u = 0; u < unicharset.size(); ++u) {
|
for (int u = 0; u < unicharset.size(); ++u) {
|
||||||
RecodedCharID code;
|
RecodedCharID code;
|
||||||
code.Set(0, u);
|
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
|
// Sets up an encoder directly using the given encoding vector, which maps
|
||||||
// unichar_ids to the given codes.
|
// unichar_ids to the given codes.
|
||||||
void UnicharCompress::SetupDirect(const GenericVector<RecodedCharID>& codes) {
|
void UnicharCompress::SetupDirect(const std::vector<RecodedCharID>& codes) {
|
||||||
encoder_ = codes;
|
encoder_ = codes;
|
||||||
ComputeCodeRange();
|
ComputeCodeRange();
|
||||||
SetupDecoder();
|
SetupDecoder();
|
||||||
@ -298,12 +298,13 @@ int UnicharCompress::DecodeUnichar(const RecodedCharID& code) const {
|
|||||||
|
|
||||||
// Writes to the given file. Returns false in case of error.
|
// Writes to the given file. Returns false in case of error.
|
||||||
bool UnicharCompress::Serialize(TFile* fp) const {
|
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.
|
// Reads from the given file. Returns false in case of error.
|
||||||
bool UnicharCompress::DeSerialize(TFile* fp) {
|
bool UnicharCompress::DeSerialize(TFile* fp) {
|
||||||
if (!encoder_.DeSerializeClasses(fp)) return false;
|
if (!fp->DeSerializeClasses(encoder_))
|
||||||
|
return false;
|
||||||
ComputeCodeRange();
|
ComputeCodeRange();
|
||||||
SetupDecoder();
|
SetupDecoder();
|
||||||
return true;
|
return true;
|
||||||
|
@ -153,7 +153,7 @@ class TESS_API UnicharCompress {
|
|||||||
void SetupPassThrough(const UNICHARSET& unicharset);
|
void SetupPassThrough(const UNICHARSET& unicharset);
|
||||||
// Sets up an encoder directly using the given encoding vector, which maps
|
// Sets up an encoder directly using the given encoding vector, which maps
|
||||||
// unichar_ids to the given codes.
|
// 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
|
// 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
|
// 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.
|
// 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.
|
// 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.
|
// Decoder converts the output of encoder back to a unichar-id.
|
||||||
std::unordered_map<RecodedCharID, int, RecodedCharID::RecodedCharIDHash>
|
std::unordered_map<RecodedCharID, int, RecodedCharID::RecodedCharIDHash> decoder_;
|
||||||
decoder_;
|
|
||||||
// True if the index is a valid single or start code.
|
// True if the index is a valid single or start code.
|
||||||
GenericVector<bool> is_valid_start_;
|
GenericVector<bool> is_valid_start_;
|
||||||
// Maps a prefix code to a list of valid next codes.
|
// Maps a prefix code to a list of valid next codes.
|
||||||
|
Loading…
Reference in New Issue
Block a user