I have a std::map<std::string, AnyType> with following item keys:
/abc/def/ghi
/abc/def/jkl
/abc/def/mno
/abc/pqr/ghi
/abc/pqr/stw
/abc/xyz/ghi
/abc/xyz/jkl
/abc/xyz/mno
/abc/zzz/mno
is there efficient way to find two iterators that determines upper and lower bounds of the range of keys that partially match with a specified string? For example, the string /abc/x should correspond to two iterators pointing consecutively to: /abc/xyz/ghi and /abc/xyz/mno.
map.lower_boundandupper_bound?/abc/ywould be inserted between/abc/xyz/mnoand/abc/zzz/mno, and that insertion point is the exact end of your range?lower_boundlooks like just 30% of problem solution.lower_boundon/abc/xand/abc/x\xFF(this way you don't need to figure out what character alphabetically follows the last character of the string; which is easy withxbut may be tricky with, say,z).\xFFcomes before or afterx. If it's -1 (char is signed) that won't work.