By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,665 Members | 1,406 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,665 IT Pros & Developers. It's quick & easy.

case insensitive find on case sensitive stl map

P: n/a
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.

Apr 6 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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
Apr 6 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.