I need to use a Tree Set data structure(available in java) in C++, and make use of functions like TreeSet.lower(i) and TreeSet.higher(i) - > which returns the element just lower, and just higher than i in the given tree set. Is there an STL?
Edit: Following is the functionality I need, I was wondering how to use the upper_bound and lower_bound functions to do it:
for (int i = 1; i<10; i++) myset.insert(i * 10); // 10 20 30 40 50 60 70 80 90
int k = 50; // I need 40 and 60
set<int>::iterator itr = myset.find(k);
if (itr != myset.end()) {
// Found the element
itr--; // Previous element;
cout << *(itr); //prints 40
itr++; // the element found
itr++; // The next element
cout << *(itr); // prints 60
}