An obvious (naive?) approach would be:
std::set s;
for (int i = 0; i < SIZE; ++i) {
s.insert(i);
}
That\'s reasonable rea
Well you can use the insert()
version of set<>
in which you can provide the position as hint where the element might get inserted.
iterator insert ( iterator position, const value_type& x );
Complexity: This version is logarithmic in general, but amortized constant if x
is inserted right after the element pointed by position.