Re: map/multimap/wildcards
- From: "Stephen Howe" <stephenPOINThoweATtns-globalPOINTcom>
- Date: Thu, 8 Jun 2006 22:18:10 +0100
I'm confused. How can I define two comparison objects in a multimap?
You cannot
I need to use the regular strcmp (compare the full length of string 1
to string 2) for inserting objects into the multimap.
Yes
I need to use the strncmp(a,b,N) with the match pattern (using the
length of the match pattern) for finding objects in the multimap.
No you don't. You use the regular strcmp() same as before. In fact, what
ever COMP method is in force for the multimap, you use the same thing. The
trick is you achieve the same objective by making use of what
lower_bound(), upper_bound(), equal_range() returns and _NOT_ by changing
your COMP method.
lower_bound() returns an iterator to the first position that the element
searched for can be inserted without disturbing the order.
upper_bound() returns an iterator to the last position that the element
searched for can be inserted without disturbing the order.
equal_range() does both and if the iterators returned are identical, no
element of the looked-for-value is present.
This behaviour allows you to look for non-exact matches => exactly what you
want.
Stephen Howe
.
- References:
- map/multimap/wildcards
- From: Jason S
- Re: map/multimap/wildcards
- From: Igor Tandetnik
- Re: map/multimap/wildcards
- From: Jason S
- map/multimap/wildcards
- Prev by Date: Re: map/multimap/wildcards
- Next by Date: Re: map/multimap/wildcards
- Previous by thread: Re: map/multimap/wildcards
- Next by thread: Re: map/multimap/wildcards
- Index(es):
Relevant Pages
|
Loading