From b5101b78560c517f6e1df5db336bb519a72d47fd Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Mon, 15 Jan 2024 21:22:57 -0600 Subject: [PATCH] App/Toponaming: Add Comparator for mapped elements --- src/App/MappedElement.cpp | 102 ++++++++++++++++++++++++++++++++++++++ src/App/MappedElement.h | 16 ++++++ 2 files changed, 118 insertions(+) diff --git a/src/App/MappedElement.cpp b/src/App/MappedElement.cpp index 14eb6f99ba917..5df937adfe9ec 100644 --- a/src/App/MappedElement.cpp +++ b/src/App/MappedElement.cpp @@ -22,3 +22,105 @@ #include "PreCompiled.h" #include "MappedElement.h" + +using namespace Data; + +bool ElementNameComparator::operator()(const MappedName &a, const MappedName &b) const { + size_t size = std::min(a.size(),b.size()); + if(!size) + return a.size()bc) + res = 1; + } + }else if(std::isxdigit(ac)) + return false; + else + break; + } + if(res < 0) + return true; + else if(res > 0) + return false; + + for (; i bc) + return false; + } + return a.size()bc) + return false; + } else if(!std::isdigit(ac)) { + return false; + } else + break; + } + + // Then compare the following digits part by integer value + int res = 0; + for(;ibc) + res = 1; + } + }else if(std::isdigit(ac)) + return false; + else + break; + } + if(res < 0) + return true; + else if(res > 0) + return false; + + // Finally, compare the remaining tail using lexical order + for (; i bc) + return false; + } + return a.size()