File: levenshtein.h

package info (click to toggle)
martchus-cpp-utilities 5.28.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,352 kB
  • sloc: cpp: 12,471; awk: 18; ansic: 12; makefile: 10
file content (25 lines) | stat: -rw-r--r-- 767 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#ifndef CPP_UTILITIES_LEVENSHTEIN_H
#define CPP_UTILITIES_LEVENSHTEIN_H

#include "../global.h"

#include <cstring>
#include <string>

namespace CppUtilities {

CPP_UTILITIES_EXPORT std::size_t computeDamerauLevenshteinDistance(const char *str1, std::size_t size1, const char *str2, std::size_t size2);

inline std::size_t computeDamerauLevenshteinDistance(const std::string &str1, const std::string &str2)
{
    return computeDamerauLevenshteinDistance(str1.data(), str1.size(), str2.data(), str2.size());
}

inline std::size_t computeDamerauLevenshteinDistance(const char *str1, const char *str2)
{
    return computeDamerauLevenshteinDistance(str1, std::strlen(str1), str2, std::strlen(str2));
}

} // namespace CppUtilities

#endif // CPP_UTILITIES_LEVENSHTEIN_H