F
Fred Zwarts
I have an application which uses maps.
I need to find elements in the map, without knowing the exact key value.
I thought I could use the lower_bound, or upper_bound function for this purpose.
However, after searching the internet and after some experiments with a few compilers
I am completely confused.
I find several contradictory descriptions of these functions. Also the results from test
programs are not clear to me.
So, maybe someone can help me, with the following example.
Suppose I have a map with keys of type int.
This map is populated with three elements, with key values 1, 3 and 7.
Which values should be returned by lower_bound and upper_bound when these are called
with parameter values 0, 1, 2, 3, 4, 5, 6, 7, 8?
Can someone fill in this table:
Parameter value 0 1 2 3 4 5 6 7 8
result of lower_bound
result of upper_bound
Thanks,
Fred.Zwarts.
I need to find elements in the map, without knowing the exact key value.
I thought I could use the lower_bound, or upper_bound function for this purpose.
However, after searching the internet and after some experiments with a few compilers
I am completely confused.
I find several contradictory descriptions of these functions. Also the results from test
programs are not clear to me.
So, maybe someone can help me, with the following example.
Suppose I have a map with keys of type int.
This map is populated with three elements, with key values 1, 3 and 7.
Which values should be returned by lower_bound and upper_bound when these are called
with parameter values 0, 1, 2, 3, 4, 5, 6, 7, 8?
Can someone fill in this table:
Parameter value 0 1 2 3 4 5 6 7 8
result of lower_bound
result of upper_bound
Thanks,
Fred.Zwarts.