liblevenshtein 4.0.0
A library for generating Finite State Transducers based on Levenshtein Automata.
Loading...
Searching...
No Matches
std::hash< liblevenshtein::DawgNode > Struct Reference

Overloaded hash template struct that serves to generate hash codes for DAWG nodes. More...

#include <dawg_node.h>

Collaboration diagram for std::hash< liblevenshtein::DawgNode >:

Public Member Functions

auto operator() (const liblevenshtein::DawgNode &node) const -> size_t
 Generates the hash code for a DAWG node.
 

Detailed Description

Overloaded hash template struct that serves to generate hash codes for DAWG nodes.

Definition at line 112 of file dawg_node.h.

Member Function Documentation

◆ operator()()

Generates the hash code for a DAWG node.

Parameters
nodeDAWG node whose hash code is to be generated.
Returns
Hash code for the given DAWG node.

Definition at line 93 of file dawg_node.cpp.

94 {
95
96 uint64_t hash_code = 0xDEADBEEF;
97 std::array<uint64_t, 1> key = {0};
98
99 node.for_each_edge([&](char label, liblevenshtein::DawgNode *target) {
100 key[0] = (unsigned char) label;
101 hash_code = MurmurHash64A(key.data(), 1, hash_code);
102
103 key[0] = (*this)(*target);
104 hash_code = MurmurHash64A(key.data(), 1, hash_code);
105 });
106
107 key[0] = (uint64_t) node.is_final();
108 return MurmurHash64A(key.data(), 1, hash_code);
109}
Represents a position within one or more terms of a DAWG dictionary.
Definition dawg_node.h:20
void is_final(bool is_final)
Specifies whether this node represents a word boundary, or immediately follows an edge having the fin...
Definition dawg_node.cpp:19
void for_each_edge(const std::function< void(char, DawgNode *)> &fn) const
Iterates over each outgoing edge of this node and invokes a callback function with each edge's charac...
Definition dawg_node.cpp:27
void query(ll::Dawg *dawg, const std::string &query_term, std::size_t max_distance)
Definition main.cpp:25

References query().

Here is the call graph for this function:

The documentation for this struct was generated from the following files: