19#ifndef TESSERACT_CCUTIL_INDEXMAPBIDI_H_
20#define TESSERACT_CCUTIL_INDEXMAPBIDI_H_
51 virtual int SparseToCompact(
int sparse_index)
const;
56 return compact_map_[compact_index];
64 return compact_map_.size();
113 void InitAndSetupRange(
int sparse_size,
int start,
int end);
119 void Init(
int size,
bool all_mapped);
121 void SetMap(
int sparse_index,
bool mapped);
130 bool Merge(
int compact_index1,
int compact_index2);
133 return MasterCompactIndex(index) < 0;
137 void CompleteMerges();
141 return sparse_map_[sparse_index];
145 return sparse_map_.size();
162 int MapFeatures(
const std::vector<int> &sparse, std::vector<int> *compact)
const;
168 int MasterCompactIndex(
int compact_index)
const {
169 while (compact_index >= 0 && sparse_map_[compact_map_[compact_index]] != compact_index) {
170 compact_index = sparse_map_[compact_map_[compact_index]];
172 return compact_index;
176 std::vector<int32_t> sparse_map_;
bool DeSerialize(bool swap, FILE *fp, std::vector< T > &data)
bool Serialize(FILE *fp, const std::vector< T > &data)
virtual int SparseSize() const
std::vector< int32_t > compact_map_
int CompactToSparse(int compact_index) const
int SparseSize() const override
int SparseToCompact(int sparse_index) const override
bool IsCompactDeleted(int index) const