16 #ifndef LLVM_ADT_EDIT_DISTANCE_H
17 #define LLVM_ADT_EDIT_DISTANCE_H
44 bool AllowReplacements =
true,
45 unsigned MaxEditDistance = 0) {
61 const unsigned SmallBufferSize = 64;
62 unsigned SmallBuffer[SmallBufferSize];
63 std::unique_ptr<unsigned[]> Allocated;
64 unsigned *Row = SmallBuffer;
65 if (n + 1 > SmallBufferSize) {
66 Row =
new unsigned[n + 1];
70 for (
unsigned i = 1;
i <= n; ++
i)
75 unsigned BestThisRow = Row[0];
77 unsigned Previous = y - 1;
80 if (AllowReplacements) {
82 Previous + (FromArray[y-1] == ToArray[x-1] ? 0u : 1u),
86 if (FromArray[y-1] == ToArray[x-1]) Row[x] = Previous;
87 else Row[x] =
std::min(Row[x-1], Row[x]) + 1;
90 BestThisRow =
std::min(BestThisRow, Row[x]);
93 if (MaxEditDistance && BestThisRow > MaxEditDistance)
94 return MaxEditDistance + 1;
97 unsigned Result = Row[n];
unsigned ComputeEditDistance(ArrayRef< T > FromArray, ArrayRef< T > ToArray, bool AllowReplacements=true, unsigned MaxEditDistance=0)
Determine the edit distance between two sequences.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
size_t size() const
size - Get the array size.
Maximum length of the test input libFuzzer tries to guess a good value based on the corpus and reports it always prefer smaller inputs during the corpus shuffle When libFuzzer itself reports a bug this exit code will be used If indicates the maximal total time in seconds to run the fuzzer minimizes the provided crash input Use with etc Experimental Use value profile to guide fuzzing Number of simultaneous worker processes to run the jobs If min(jobs, NumberOfCpuCores()/2)\" is used.") FUZZER_FLAG_INT(reload