Tesseract
3.02
|
#include <search_node.h>
Public Member Functions | |
SearchNodeHashTable () | |
~SearchNodeHashTable () | |
bool | Insert (LangModEdge *lang_mod_edge, SearchNode *srch_node) |
SearchNode * | Lookup (LangModEdge *lang_mod_edge, SearchNode *parent_node) |
Definition at line 109 of file search_node.h.
tesseract::SearchNodeHashTable::SearchNodeHashTable | ( | ) | [inline] |
Definition at line 111 of file search_node.h.
{
memset(bin_size_array_, 0, sizeof(bin_size_array_));
}
tesseract::SearchNodeHashTable::~SearchNodeHashTable | ( | ) | [inline] |
Definition at line 115 of file search_node.h.
{ }
bool tesseract::SearchNodeHashTable::Insert | ( | LangModEdge * | lang_mod_edge, |
SearchNode * | srch_node | ||
) | [inline] |
Definition at line 119 of file search_node.h.
{ // compute hash based on the edge and its parent node edge unsigned int edge_hash = lang_mod_edge->Hash(); unsigned int parent_hash = (srch_node->ParentNode() == NULL ? 0 : srch_node->ParentNode()->LangModelEdge()->Hash()); unsigned int hash_bin = (edge_hash + parent_hash) % kSearchNodeHashBins; // already maxed out, just fail if (bin_size_array_[hash_bin] >= kMaxSearchNodePerBin) { return false; } bin_array_[hash_bin][bin_size_array_[hash_bin]++] = srch_node; return true; }
SearchNode* tesseract::SearchNodeHashTable::Lookup | ( | LangModEdge * | lang_mod_edge, |
SearchNode * | parent_node | ||
) | [inline] |
Definition at line 137 of file search_node.h.
{ // compute hash based on the edge and its parent node edge unsigned int edge_hash = lang_mod_edge->Hash(); unsigned int parent_hash = (parent_node == NULL ? 0 : parent_node->LangModelEdge()->Hash()); unsigned int hash_bin = (edge_hash + parent_hash) % kSearchNodeHashBins; // lookup the entries in the hash bin for (int node_idx = 0; node_idx < bin_size_array_[hash_bin]; node_idx++) { if (lang_mod_edge->IsIdentical( bin_array_[hash_bin][node_idx]->LangModelEdge()) == true && SearchNode::IdenticalPath( bin_array_[hash_bin][node_idx]->ParentNode(), parent_node) == true) { return bin_array_[hash_bin][node_idx]; } } return NULL; }