aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-12-30 17:23:44 +0000
committerDouglas Gregor <dgregor@apple.com>2009-12-30 17:23:44 +0000
commit441c8b4ad17c0d029b2247c367111395e7ad068c (patch)
treefd7a1d57e11e237fab718c328d99e73a226d5dcf /include
parent7fccf76048b66c2526197063feb133e706a48ad4 (diff)
downloadexternal_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.h16
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); }