MCPcopy Create free account
hub / github.com/comaps/comaps / AlmostEqual

Function AlmostEqual

libs/base/string_utils.cpp:448–466  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

446}
447
448bool AlmostEqual(std::string const & str1, std::string const & str2, size_t mismatchedCount)
449{
450 std::pair mis(str1.begin(), str2.begin());
451 auto const str1End = str1.end();
452 auto const str2End = str2.end();
453
454 for (size_t i = 0; i <= mismatchedCount; ++i)
455 {
456 auto const end = mis.first + std::min(distance(mis.first, str1End), distance(mis.second, str2End));
457 mis = mismatch(mis.first, end, mis.second);
458 if (mis.first == str1End && mis.second == str2End)
459 return true;
460 if (mis.first != str1End)
461 ++mis.first;
462 if (mis.second != str2End)
463 ++mis.second;
464 }
465 return false;
466}
467
468namespace
469{

Callers 1

UNIT_TESTFunction · 0.85

Calls 3

distanceFunction · 0.85
beginMethod · 0.45
endMethod · 0.45

Tested by 1

UNIT_TESTFunction · 0.68