All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
tesseract::SearchNodeHashTable Class Reference

#include <search_node.h>

Public Member Functions

 SearchNodeHashTable ()
 
 ~SearchNodeHashTable ()
 
bool Insert (LangModEdge *lang_mod_edge, SearchNode *srch_node)
 
SearchNodeLookup (LangModEdge *lang_mod_edge, SearchNode *parent_node)
 

Detailed Description

Definition at line 109 of file search_node.h.

Constructor & Destructor Documentation

tesseract::SearchNodeHashTable::SearchNodeHashTable ( )
inline

Definition at line 111 of file search_node.h.

111  {
112  memset(bin_size_array_, 0, sizeof(bin_size_array_));
113  }
tesseract::SearchNodeHashTable::~SearchNodeHashTable ( )
inline

Definition at line 115 of file search_node.h.

115  {
116  }

Member Function Documentation

bool tesseract::SearchNodeHashTable::Insert ( LangModEdge lang_mod_edge,
SearchNode srch_node 
)
inline

Definition at line 119 of file search_node.h.

119  {
120  // compute hash based on the edge and its parent node edge
121  unsigned int edge_hash = lang_mod_edge->Hash();
122  unsigned int parent_hash = (srch_node->ParentNode() == NULL ?
123  0 : srch_node->ParentNode()->LangModelEdge()->Hash());
124  unsigned int hash_bin = (edge_hash + parent_hash) % kSearchNodeHashBins;
125 
126  // already maxed out, just fail
127  if (bin_size_array_[hash_bin] >= kMaxSearchNodePerBin) {
128  return false;
129  }
130 
131  bin_array_[hash_bin][bin_size_array_[hash_bin]++] = srch_node;
132 
133  return true;
134  }
#define NULL
Definition: host.h:144
SearchNode* tesseract::SearchNodeHashTable::Lookup ( LangModEdge lang_mod_edge,
SearchNode parent_node 
)
inline

Definition at line 137 of file search_node.h.

138  {
139  // compute hash based on the edge and its parent node edge
140  unsigned int edge_hash = lang_mod_edge->Hash();
141  unsigned int parent_hash = (parent_node == NULL ?
142  0 : parent_node->LangModelEdge()->Hash());
143  unsigned int hash_bin = (edge_hash + parent_hash) % kSearchNodeHashBins;
144 
145  // lookup the entries in the hash bin
146  for (int node_idx = 0; node_idx < bin_size_array_[hash_bin]; node_idx++) {
147  if (lang_mod_edge->IsIdentical(
148  bin_array_[hash_bin][node_idx]->LangModelEdge()) == true &&
150  bin_array_[hash_bin][node_idx]->ParentNode(), parent_node) == true) {
151  return bin_array_[hash_bin][node_idx];
152  }
153  }
154 
155  return NULL;
156  }
static bool IdenticalPath(SearchNode *node1, SearchNode *node2)
#define NULL
Definition: host.h:144

The documentation for this class was generated from the following file: