be*******@gmail.com wrote:
I have been searching around and have not been able to find any info
on this. I have a unique situation where I need a case sensitive map:
std::map<string, intimap;
I need to be able to run a find on this map with a case sensitive AND
case insensitive search. I need to be able to change this dynamically
during execution. Is this possible? Any thoughts on this? I
understand that I can make the map case insensitive, but that is not
what I need.
How about a custom comparison function which will sort such that all
strings which differ only in case are adjacent to one another? There
are a number of ways to achieve this.
Then, for case insensitive search, you can use lower_bound or
upper_bound instead of find and efficiently look at adjacent map
elements with the same letters modulo capitalization.
Another possibility is to use multimap instead of map but this, unlike
the above approach, will allow multiple identical keys and you may have
to look at all cases even for case sensitive search.
-Mark