how to extract a range from stl set..like if i have to extract all the elements from x-h to x+h from a set ...hw can i do it in log n time?? i am trying to use lower_bound and upper_bound and iterating between the iterators found by them but its giving a lot of error to me..
plzz help..
plzz help..
what kind of errors?
i have checked this code:
#include<set>
#include<utility>
using namespace std;
int main()
{
int h=0;int x=0;
set<pair<int,int> >s;
for(set<pair<int,int> >::iterator it=s.lower_bound(make_pair(x-h,0));it!=s.upper_bound(make_pair(x+h,0));it++)
{
//processing here;
}
}
on my VS 2008 and on C++ (gcc-4.3.4)(using ideone.com) and both of them compiled it without any errors or warnings.I think the region "//processing here" has some errors :).