I am trying to find the next / previous neighbor of an element in std::set.
I tried doing something like:
std::set<int> s;
for (int i = 0; i < 10; ++i) {
s.insert(i);
}
std::set<int>::iterator iter = s.find(5);
EXPECT_EQ(5, *(iter++));
But it not work.
At a high level, it seems like from a red-black tree it is possible to find the next / previous element in O(logN), so the question is does std::set support it?