|
Tesseract
3.02
|
#include "freelist.h"#include "closed.h"#include "cutil.h"#include "callcpp.h"#include <assert.h>Go to the source code of this file.
Defines | |
| #define | TABLE_SIZE 2000 |
Functions | |
hash_add | |
Look in the hash table for a particular value. If it is not there then add it. | |
| int | hash_add (HASH_TABLE state_table, STATE *state) |
hash_lookup | |
Look in the hash table for a particular value. If the value is there then return TRUE, FALSE otherwise. | |
| int | hash_lookup (HASH_TABLE state_table, STATE *state) |
new_hash_table | |
Create and initialize a hash table. | |
| HASH_TABLE | new_hash_table () |
| #define TABLE_SIZE 2000 |
Definition at line 39 of file closed.cpp.
| int hash_add | ( | HASH_TABLE | state_table, |
| STATE * | state | ||
| ) |
Definition at line 50 of file closed.cpp.
{
int x;
int i = 0;
int table_limit = TABLE_SIZE;
x = state->part2 % table_limit;
while (i < table_limit) {
assert (0 <= x && x < table_limit);
/* Found it */
if ((state_table[x].part2 == state->part2) &&
(state_table[x].part1 == state->part1)) {
return (FALSE);
}
/* Not in table */
else if (state_table[x].part1 == NO_STATE) {
state_table[x].part2 = state->part2;
state_table[x].part1 = state->part1;
return (TRUE);
}
i++;
if (++x >= table_limit)
x = 0;
}
cprintf("warning: hash table is full");
abort();
return 0;
}
| int hash_lookup | ( | HASH_TABLE | state_table, |
| STATE * | state | ||
| ) |
Definition at line 86 of file closed.cpp.
{
int x;
int i = 0;
int table_limit = TABLE_SIZE;
x = state->part2 % table_limit;
while (i < table_limit) {
assert (0 <= x && x < table_limit);
/* Found it */
if ((state_table[x].part2 == state->part2) &&
(state_table[x].part1 == state->part1)) {
return (TRUE);
}
/* Not in table */
else if (state_table[x].part1 == NO_STATE) {
return (FALSE);
}
i++;
if (++x >= table_limit)
x = 0;
}
cprintf ("warning: fell off end of hash table (%x) %x\n",
state->part2, state->part2 % table_limit);
abort();
return 0;
}
| HASH_TABLE new_hash_table | ( | ) |
Definition at line 120 of file closed.cpp.
{
HASH_TABLE ht;
int x;
ht = (HASH_TABLE) memalloc (TABLE_SIZE * sizeof (STATE));
for (x = 0; x < TABLE_SIZE; x++) {
ht[x].part1 = NO_STATE;
ht[x].part2 = NO_STATE;
}
return (ht);
}