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
5
#include "
liblevenshtein/distance/symmetric_pair.h
"
6
7
namespace
liblevenshtein::distance
{
8
9
SymmetricPair::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
19
auto
SymmetricPair::operator==
(
const
SymmetricPair
&
other
)
const
->
bool
{
20
return
(first ==
other
.first) && (second ==
other
.second);
21
}
22
23
auto
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
32
namespace
std
{
33
34
namespace
lld
=
liblevenshtein::distance
;
35
36
auto
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
liblevenshtein::distance::SymmetricPair
Represents a pair of terms sorted, lexicographically, in ascending order.
Definition
symmetric_pair.h:12
liblevenshtein::distance::SymmetricPair::SymmetricPair
SymmetricPair(const std::string &u, const std::string &v)
Constructs a SymmetricPair of terms such that the first term is the lesser, lexicographically,...
Definition
symmetric_pair.cpp:9
liblevenshtein::distance::SymmetricPair::second
std::string second
The lexicographically greater term of the pair.
Definition
symmetric_pair.h:45
liblevenshtein::distance::SymmetricPair::first
std::string first
The lexicographically lesser term of the pair.
Definition
symmetric_pair.h:42
liblevenshtein::distance::SymmetricPair::operator==
auto operator==(const SymmetricPair &other) const -> bool
Determines whether this SymmetricPair is equivalent to another.
Definition
symmetric_pair.cpp:19
query
void query(ll::Dawg *dawg, const std::string &query_term, std::size_t max_distance)
Definition
main.cpp:25
liblevenshtein::distance
Memoized, recursive distance metrics typically used to evaluate the correctness of Levenshtein automa...
Definition
namespaces.dox:16
liblevenshtein::distance::operator<<
auto operator<<(std::ostream &out, const SymmetricPair &pair) -> std::ostream &
Definition
symmetric_pair.cpp:23
std
STL namespace.
symmetric_pair.h
src
liblevenshtein
distance
symmetric_pair.cpp
Generated by
1.10.0