diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-12-30 17:23:44 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-12-30 17:23:44 +0000 |
commit | 441c8b4ad17c0d029b2247c367111395e7ad068c (patch) | |
tree | fd7a1d57e11e237fab718c328d99e73a226d5dcf /include | |
parent | 7fccf76048b66c2526197063feb133e706a48ad4 (diff) | |
download | external_llvm-441c8b4ad17c0d029b2247c367111395e7ad068c.zip external_llvm-441c8b4ad17c0d029b2247c367111395e7ad068c.tar.gz external_llvm-441c8b4ad17c0d029b2247c367111395e7ad068c.tar.bz2 |
Implement edit distance for StringRef
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92309 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/llvm/ADT/StringRef.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/include/llvm/ADT/StringRef.h b/include/llvm/ADT/StringRef.h index a744266..1c73836 100644 --- a/include/llvm/ADT/StringRef.h +++ b/include/llvm/ADT/StringRef.h @@ -133,6 +133,22 @@ namespace llvm { /// compare_lower - Compare two strings, ignoring case. int compare_lower(StringRef RHS) const; + /// \brief Determine the edit distance between this string and another + /// string. + /// + /// \param Other the string to compare this string against. + /// + /// \param AllowReplacements whether to allow character + /// replacements (change one character into another) as a single + /// operation, rather than as two operations (an insertion and a + /// removal). + /// + /// \returns the minimum number of character insertions, removals, + /// or (if \p AllowReplacements is \c true) replacements needed to + /// transform one of the given strings into the other. If zero, + /// the strings are identical. + unsigned edit_distance(StringRef Other, bool AllowReplacements = true); + /// str - Get the contents as an std::string. std::string str() const { return std::string(Data, Length); } |