tesseract
5.0.0-alpha-619-ge9db
|
Go to the documentation of this file.
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;
69 table_.set_clear_callback(cb);
75 table_.set_compare_callback(cb);
93 bool write(FILE* f, std::function<
bool(FILE*,
const T&)> cb)
const {
94 return table_.write(f, cb);
97 return table_.read(f, cb);
102 std::function<bool(
const T&,
const T&)> compare_cb_;
105 template <
typename T>
109 using namespace std::placeholders;
111 std::bind(tesseract::cmp_eq<T>, _1, _2));
115 template <
typename T>
117 compare_cb_(nullptr) {
121 template <
typename T>
126 template <
typename T>
128 return table_.size();
133 template <
typename T>
135 table_.reserve(size);
139 template <
typename T>
141 return table_.get(
id);
144 template <
typename T>
146 return &(table_.get(
id));
149 template <
typename T>
151 return table_.contains_index(
id);
155 template <
typename T>
157 return table_.get_index(
object);
161 template <
typename T>
163 return get_id(
object) != -1;
167 template <
typename T>
169 int idx = get_id(
object);
171 idx = table_.push_back(
object);
177 template <
typename T>
184 template <
typename T>
186 table_.move(&from->table_);
189 #endif // TESSERACT_CCUTIL_UNICITY_TABLE_H_
bool contains(T object) const
Return true if T is in the table.
int get_id(T object) const
int push_back(T object)
Add an element in the table.
void set_compare_callback(std::function< bool(const T &, const T &)> cb)
bool read(tesseract::TFile *f, std::function< bool(tesseract::TFile *, T *)> cb)
const T & get(int id) const
Return the object from an id.
int size() const
Return the size used.
bool write(FILE *f, std::function< bool(FILE *, const T &)> cb) const
void set_clear_callback(std::function< void(T)> cb)
T contains_id(int id) const
Return true if the id is valid.
~UnicityTable()
Clear the structures and deallocate internal structures.
void move(UnicityTable< T > *from)