Tesseract  3.02
tesseract::SearchNodeHashTable Class Reference

#include <search_node.h>

List of all members.

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.

                        {
    memset(bin_size_array_, 0, sizeof(bin_size_array_));
  }
tesseract::SearchNodeHashTable::~SearchNodeHashTable ( ) [inline]

Definition at line 115 of file search_node.h.

                         {
  }

Member Function Documentation

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;
  }

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