liblevenshtein 4.0.0
A library for generating Finite State Transducers based on Levenshtein Automata.
Loading...
Searching...
No Matches
symmetric_pair.cpp
Go to the documentation of this file.
1#include <cstdint>
2
3#include "MurmurHash2.h"
4
6
8
9SymmetricPair::SymmetricPair(const std::string &u, const std::string &v) {
10 if (u.compare(v) < 0) {
11 this->first = u;
12 this->second = v;
13 } else {
14 this->first = v;
15 this->second = u;
16 }
17}
18
19auto SymmetricPair::operator==(const SymmetricPair &other) const -> bool {
20 return (first == other.first) && (second == other.second);
21}
22
23auto operator<<(std::ostream &out, const SymmetricPair &pair)
24 -> std::ostream & {
25 out << "SymmetricPair{first=\"" << pair.first << "\", second=\""
26 << pair.second << "\"}";
27 return out;
28}
29
30} // namespace liblevenshtein::distance
31
32namespace std {
33
35
36auto hash<lld::SymmetricPair>::operator()(const lld::SymmetricPair &pair) const
37 -> size_t {
38 uint64_t hash_code = 0xDEADBEEF;
39 hash_code =
40 MurmurHash64A(pair.first.c_str(), (int)pair.first.length(), hash_code);
41 return MurmurHash64A(pair.second.c_str(), (int)pair.second.length(),
42 hash_code);
43}
44
45} // namespace std
Represents a pair of terms sorted, lexicographically, in ascending order.
SymmetricPair(const std::string &u, const std::string &v)
Constructs a SymmetricPair of terms such that the first term is the lesser, lexicographically,...
std::string second
The lexicographically greater term of the pair.
std::string first
The lexicographically lesser term of the pair.
auto operator==(const SymmetricPair &other) const -> bool
Determines whether this SymmetricPair is equivalent to another.
void query(ll::Dawg *dawg, const std::string &query_term, std::size_t max_distance)
Definition main.cpp:25
Memoized, recursive distance metrics typically used to evaluate the correctness of Levenshtein automa...
auto operator<<(std::ostream &out, const SymmetricPair &pair) -> std::ostream &
STL namespace.