|
Boost Users : |
From: Phil Endecott (spam_from_boost_users_at_[hidden])
Date: 2022-07-20 21:25:42
Dear Experts,
I currently have:
template <typename KEY, typename VALUE, size_t SZ>
using small_flat_map =
boost::container::flat_map<
KEY,
VALUE,
std::less<KEY>,
boost::container::small_vector<
std::pair<KEY,VALUE>,
SZ
>
>;
This works OK, but one thing that I do with it quite often is
auto i = m.upper_bound(...);
m.erase(m.begin(),i);
Erasing items at the start of the vector is of course the worst
thing you can do for performance with a flat_map. So I was wondering
if I can have a flat_map that stores its elements in the reverse
order in the underlying vector.
Question: can anyone think of a way to do this that doesn't
require changing all of the downstream code? For a few
milliseconds I thought I could just change std::less for
std::greater but that reverses the externally-visible
behaviour. Is there some Boost utility that can wrap the
implementation vector to work in reverse?
Thanks,
Phil.
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