c++ - finding wildcard entries efficiently -
    i have map contains strings keys; string resemble wildcards.   a key can have *  @ end, means when lookup performed, string has key prefix shall match key.   how can efficiently retrieve closest matching entry in such map?   i tried sorting map entries in custom way , using lower_bound , sorting not produce correct result:   #include <map> #include <string> #include <iostream> #include <algorithm>  struct compare {     bool operator()(const std::string& lhs, const std::string& rhs) const     {         if (lhs.size() < rhs.size()) {             return true;         }          if (lhs.size() > rhs.size()) {             return false;         }          bool iswildcardlhsatend = (!lhs.empty() && lhs.back() == '*');         bool iswildcardrhsatend = (!rhs.empty() && rhs.back() == '*');          if (iswildcardlhsatend && iswildcardrhsatend) {             return lhs < rhs;         }         auto lhsubstring =...