20 #ifndef TESSERACT_CCUTIL_INDEXMAPBIDI_H_ 21 #define TESSERACT_CCUTIL_INDEXMAPBIDI_H_ 117 void Init(
int size,
bool all_mapped);
119 void SetMap(
int sparse_index,
bool mapped);
128 bool Merge(
int compact_index1,
int compact_index2);
131 return MasterCompactIndex(index) < 0;
139 return sparse_map_[sparse_index];
143 return sparse_map_.
size();
167 int MasterCompactIndex(
int compact_index)
const {
168 while (compact_index >= 0 &&
169 sparse_map_[
compact_map_[compact_index]] != compact_index)
170 compact_index = sparse_map_[
compact_map_[compact_index]];
171 return compact_index;
180 #endif // TESSERACT_CCUTIL_INDEXMAPBIDI_H_
int CompactToSparse(int compact_index) const
void SetMap(int sparse_index, bool mapped)
void CopyFrom(const IndexMapBiDi &src)
GenericVector< int32_t > compact_map_
bool Serialize(FILE *fp) const
virtual int SparseSize() const
int MapFeatures(const GenericVector< int > &sparse, GenericVector< int > *compact) const
bool Merge(int compact_index1, int compact_index2)
bool DeSerialize(bool swap, FILE *fp)
void InitAndSetupRange(int sparse_size, int start, int end)
bool IsCompactDeleted(int index) const
bool Serialize(FILE *fp) const
virtual int SparseToCompact(int sparse_index) const
void CopyFrom(const IndexMap &src)
virtual int SparseToCompact(int sparse_index) const
virtual int SparseSize() const
bool DeSerialize(bool swap, FILE *fp)
void Init(int size, bool all_mapped)