#include <indexmapbidi.h>
Definition at line 104 of file indexmapbidi.h.
◆ ~IndexMapBiDi()
tesseract::IndexMapBiDi::~IndexMapBiDi |
( |
| ) |
|
|
overridedefault |
◆ CompleteMerges()
void tesseract::IndexMapBiDi::CompleteMerges |
( |
| ) |
|
Definition at line 177 of file indexmapbidi.cpp.
179 int compact_size = 0;
180 for (
int &i : sparse_map_) {
181 int compact_index = MasterCompactIndex(i);
183 if (compact_index >= compact_size) {
184 compact_size = compact_index + 1;
190 for (
size_t i = 0; i < sparse_map_.size(); ++i) {
191 if (sparse_map_[i] >= 0) {
199 std::vector<int32_t> tmp_compact_map(compact_size, -1);
203 tmp_compact_map[i] = compact_size;
209 for (
int &i : sparse_map_) {
211 i = tmp_compact_map[i];
std::vector< int32_t > compact_map_
◆ CopyFrom()
void tesseract::IndexMapBiDi::CopyFrom |
( |
const IndexMapBiDi & |
src | ) |
|
◆ DeSerialize()
bool tesseract::IndexMapBiDi::DeSerialize |
( |
bool |
swap, |
|
|
FILE * |
fp |
|
) |
| |
Definition at line 236 of file indexmapbidi.cpp.
240 std::vector<int32_t> remaining_pairs;
249 for (
size_t i = 0; i < remaining_pairs.size(); ++i) {
250 int sparse_index = remaining_pairs[i++];
251 sparse_map_[sparse_index] = remaining_pairs[i];
bool DeSerialize(bool swap, FILE *fp, std::vector< T > &data)
bool DeSerialize(bool swap, FILE *fp)
◆ Init()
void tesseract::IndexMapBiDi::Init |
( |
int |
size, |
|
|
bool |
all_mapped |
|
) |
| |
Definition at line 97 of file indexmapbidi.cpp.
101 sparse_map_.resize(size, -1);
103 for (
int i = 0; i < size; ++i) {
◆ InitAndSetupRange()
void tesseract::IndexMapBiDi::InitAndSetupRange |
( |
int |
sparse_size, |
|
|
int |
start, |
|
|
int |
end |
|
) |
| |
Definition at line 85 of file indexmapbidi.cpp.
86 Init(sparse_size,
false);
87 for (
int i = start; i < end; ++i) {
void Init(int size, bool all_mapped)
void SetMap(int sparse_index, bool mapped)
◆ IsCompactDeleted()
bool tesseract::IndexMapBiDi::IsCompactDeleted |
( |
int |
index | ) |
const |
|
inline |
Definition at line 132 of file indexmapbidi.h.
133 return MasterCompactIndex(index) < 0;
◆ MapFeatures()
int tesseract::IndexMapBiDi::MapFeatures |
( |
const std::vector< int > & |
sparse, |
|
|
std::vector< int > * |
compact |
|
) |
| const |
Definition at line 261 of file indexmapbidi.cpp.
263 int num_features = sparse.size();
264 int missed_features = 0;
265 int prev_good_feature = -1;
266 for (
int f = 0; f < num_features; ++f) {
267 int feature = sparse_map_[sparse[f]];
269 if (feature != prev_good_feature) {
270 compact->push_back(feature);
271 prev_good_feature = feature;
277 return missed_features;
◆ Merge()
bool tesseract::IndexMapBiDi::Merge |
( |
int |
compact_index1, |
|
|
int |
compact_index2 |
|
) |
| |
Definition at line 144 of file indexmapbidi.cpp.
146 compact_index1 = MasterCompactIndex(compact_index1);
147 compact_index2 = MasterCompactIndex(compact_index2);
149 if (compact_index1 > compact_index2) {
150 int tmp = compact_index1;
151 compact_index1 = compact_index2;
152 compact_index2 = tmp;
153 }
else if (compact_index1 == compact_index2) {
160 sparse_map_[
compact_map_[compact_index2]] = compact_index1;
161 if (compact_index1 >= 0) {
◆ Serialize()
bool tesseract::IndexMapBiDi::Serialize |
( |
FILE * |
fp | ) |
const |
Definition at line 217 of file indexmapbidi.cpp.
224 std::vector<int32_t> remaining_pairs;
225 for (
unsigned i = 0; i < sparse_map_.size(); ++i) {
226 if (sparse_map_[i] >= 0 &&
static_cast<unsigned>(
compact_map_[sparse_map_[i]]) != i) {
227 remaining_pairs.push_back(i);
228 remaining_pairs.push_back(sparse_map_[i]);
bool Serialize(FILE *fp, const std::vector< T > &data)
bool Serialize(FILE *fp) const
◆ SetMap()
void tesseract::IndexMapBiDi::SetMap |
( |
int |
sparse_index, |
|
|
bool |
mapped |
|
) |
| |
Definition at line 110 of file indexmapbidi.cpp.
111 sparse_map_[sparse_index] = mapped ? 0 : -1;
◆ Setup()
void tesseract::IndexMapBiDi::Setup |
( |
| ) |
|
Definition at line 117 of file indexmapbidi.cpp.
118 int compact_size = 0;
119 for (
int &i : sparse_map_) {
126 for (
size_t i = 0; i < sparse_map_.size(); ++i) {
127 if (sparse_map_[i] >= 0) {
◆ SparseSize()
int tesseract::IndexMapBiDi::SparseSize |
( |
| ) |
const |
|
inlineoverridevirtual |
◆ SparseToCompact()
int tesseract::IndexMapBiDi::SparseToCompact |
( |
int |
sparse_index | ) |
const |
|
inlineoverridevirtual |
The documentation for this class was generated from the following files: