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>
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, swap);
203 template <
typename T>
205 table_.move(&from->table_);
208 #endif // TESSERACT_CCUTIL_UNICITY_TABLE_H_
void set_compare_callback(TessResultCallback2< bool, T const &, T const & > *cb)
bool contains(T object) const
Return true if T is in the table.
bool read(FILE *f, TessResultCallback3< bool, FILE *, T *, bool > *cb, bool swap)
swap is used to switch the endianness.
T contains_id(int id) const
Return true if the id is valid.
bool write(FILE *f, TessResultCallback2< bool, FILE *, T const & > *cb) const
int push_back(T object)
Add an element in the table.
_ConstTessMemberResultCallback_0_0< false, R, T1 >::base * NewPermanentTessCallback(const T1 *obj, R(T2::*member)() const)
~UnicityTable()
Clear the structures and deallocate internal structures.
const T & get(int id) const
Return the object from an id.
int size() const
Return the size used.
void move(UnicityTable< T > *from)
void set_clear_callback(TessCallback1< T > *cb)
int get_id(T object) const