34 #define NUM_MATCH_ENTRIES 500
39 : been_initialized_(false), match_table_(
NULL) {
53 if (been_initialized_) {
57 match_table_[x].
rating->clear();
58 delete match_table_[x].
rating;
67 been_initialized_ =
true;
72 if (been_initialized_) {
74 delete[] match_table_;
76 been_initialized_ =
false;
91 int start = Hash(bbox);
98 match_table_[x].
box = bbox;
100 match_table_[x].
rating =
new BLOB_CHOICE_LIST();
106 }
while (x != start);
108 cprintf (
"error: Match table is full\n");
128 int BlobMatchTable::Hash(
const TBOX &box)
const {
129 int topleft = (box.
top() << 16) + box.
left();
139 bool BlobMatchTable::IsEmpty(
int idx)
const {
140 return TBOX() == match_table_[idx].
box &&
151 int start = Hash(box);
159 if (match_table_[x].box == box) {
160 BLOB_CHOICE_LIST *blist =
new BLOB_CHOICE_LIST();
166 }
while (x != start);
185 int start = Hash(bbox);
189 fprintf(stderr,
"Can not update uninitialized entry in match_table\n");
192 if (match_table_[x].box == bbox) {
195 it.set_to_list(match_table_[x].rating);
196 BLOB_CHOICE_IT new_it;
197 new_it.set_to_list(ratings);
198 assert(it.length() <= new_it.length());
199 for (it.mark_cycle_pt(), new_it.mark_cycle_pt();
200 !it.cycled_list() && !new_it.cycled_list(); new_it.forward()) {
201 if (it.data()->unichar_id() == new_it.data()->unichar_id()) {
204 it.add_before_stay_put(
new BLOB_CHOICE(*(new_it.data())));
211 }
while (x != start);