MCPcopy Create free account
hub / github.com/KebsCS/KBotExt / FuzzySearch

Function FuzzySearch

KBotExt/Misc.h:376–397  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

374};
375
376inline int FuzzySearch(const char* needle, void* data)
377{
378 const auto& items = *static_cast<std::vector<std::string>*>(data);
379 for (int i = 0; i < static_cast<int>(items.size()); i++)
380 {
381 const auto haystack = items[i].c_str();
382 // empty
383 if (!needle[0])
384 {
385 if (!haystack[0])
386 return i;
387 continue;
388 }
389 // exact match
390 if (strstr(haystack, needle))
391 return i;
392 // fuzzy match
393 if (ISTRSTR(haystack, needle))
394 return i;
395 }
396 return -1;
397}
398
399static bool itemsGetter(void* data, const int n, const char** out_str)
400{

Callers 1

ComboAutoSelectComplexFunction · 0.85

Calls 2

c_strMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected