Boost logo

Boost Users :

From: Martin Wartens (martin.wartens_at_[hidden])
Date: 2005-03-28 10:39:03


Hi,
I am already using the unordered_map implementation from the file vault. I have
got some problems with unordered_map, because it offers no "lower_bound" (it is
not a problem of the implementation, it is simply not in the specs). My
question is, why is that so and what can I do about it?
The use case is an efficient insert when I have to take special actions when
the key is already in the container. For a map this would work like:
iter = lower_bound(key); which gets the first element greater or equal to key
Now I can check if the key is already in the map and execute some action to
handle this case.
Then I can insert the new element in the map with the "hint"-version of insert:
mymap.insert(iter, newelement);
The hint-version starts searching at the hint for the correct insertion point,
so we don't have to search through the map twice. It is strange that such a
hint-insert also exists for the unordered_map. But what hint could I give it,
if I don't have lower_bound?
Thanks,
Martin

PS: there is a small problem in hash_table.hpp causing a warning in VC7.1
line 278 should be:
return (*prev_ptr)!=0;
instead of
return *prev_ptr;


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net