|
Boost Users : |
Subject: [Boost-users] [MultiIndex] getting the index from set::lower_bound() iterator (or a replacement/extension)
From: U.Mutlu (for-gmane_at_[hidden])
Date: 2015-05-07 04:00:38
Hi,
I need a container like std::set which delivers also
the index when using the member function lower_bound().
IMO std::set lacks this important functionality.
I cannot use std::distance(myset.begin(), it),
because that is very slow as it walks again all the items from the beginning.
Can boost MultiIndex be used for this, or any other alternatives/workarounds?
Here's a demonstration of what I need:
struct TS { /*...*/ };
set<TS> myset;
TS S(/*...*/);
auto it = myset.lower_bound(S);
if (it != myset.end())
{
size_t ix = ...howto get the index, ie. the rank?...
//...
}
-- Thx Uenal
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