20 #ifndef TESSERACT_CCUTIL_UNICITY_TABLE_H_ 21 #define TESSERACT_CCUTIL_UNICITY_TABLE_H_ 47 const T &
get(
int id)
const;
55 int get_id(T
object)
const;
107 template <
typename T>
109 compare_cb_(nullptr) {
113 template <
typename T>
118 template <
typename T>
120 return table_.size();
125 template <
typename T>
127 table_.reserve(size);
131 template <
typename T>
133 return table_.get(
id);
136 template <
typename T>
138 return &(table_.get(
id));
141 template <
typename T>
143 return table_.contains_index(
id);
147 template <
typename T>
149 return table_.get_index(
object);
153 template <
typename T>
155 return get_id(
object) != -1;
159 template <
typename T>
161 int idx = get_id(
object);
163 idx = table_.push_back(
object);
170 template <
typename T>
172 table_.set_clear_callback(cb);
177 template <
typename T>
179 table_.set_compare_callback(cb);
184 template <
typename T>
189 template <
typename T>
192 return table_.write(f, cb);
195 template <
typename T>
198 return table_.read(f, cb);
203 template <
typename T>
205 table_.move(&from->table_);
208 #endif // TESSERACT_CCUTIL_UNICITY_TABLE_H_ void move(UnicityTable< T > *from)
bool read(tesseract::TFile *f, TessResultCallback2< bool, tesseract::TFile *, T *> *cb)
~UnicityTable()
Clear the structures and deallocate internal structures.
_ConstTessMemberResultCallback_0_0< false, R, T1 >::base * NewPermanentTessCallback(const T1 *obj, R(T2::*member)() const)
void set_clear_callback(TessCallback1< T > *cb)
void set_compare_callback(TessResultCallback2< bool, T const &, T const &> *cb)
bool write(FILE *f, TessResultCallback2< bool, FILE *, T const &> *cb) const
int size() const
Return the size used.
int get_id(T object) const
int push_back(T object)
Add an element in the table.
const T & get(int id) const
Return the object from an id.
T contains_id(int id) const
Return true if the id is valid.
bool contains(T object) const
Return true if T is in the table.