C++ Utilities  4.17.0
Useful C++ classes and routines such as argument parser, IO and conversion utilities
levenshtein.h
Go to the documentation of this file.
1 #ifndef CPP_UTILITIES_LEVENSHTEIN_H
2 #define CPP_UTILITIES_LEVENSHTEIN_H
3 
4 #include "../global.h"
5 
6 #include <cstring>
7 #include <string>
8 
9 namespace MiscUtilities {
10 
11 CPP_UTILITIES_EXPORT std::size_t computeDamerauLevenshteinDistance(const char *str1, std::size_t size1, const char *str2, std::size_t size2);
12 
13 inline std::size_t computeDamerauLevenshteinDistance(const std::string &str1, const std::string &str2)
14 {
15  return computeDamerauLevenshteinDistance(str1.data(), str1.size(), str2.data(), str2.size());
16 }
17 
18 inline std::size_t computeDamerauLevenshteinDistance(const char *str1, const char *str2)
19 {
20  return computeDamerauLevenshteinDistance(str1, std::strlen(str1), str2, std::strlen(str2));
21 }
22 
23 } // namespace MiscUtilities
24 
25 #endif // CPP_UTILITIES_LEVENSHTEIN_H
#define CPP_UTILITIES_EXPORT
CPP_UTILITIES_EXPORT std::size_t computeDamerauLevenshteinDistance(const char *str1, std::size_t size1, const char *str2, std::size_t size2)
Contains various utilities such as computing Damerau–Levenshtein distance and N-dimensional arrays.
Definition: multiarray.h:8