It removes from the set container either a single element or a range of elements.
DeclarationFollowing are the ways in which std::set::erase works in various C++ versions.
C++98void erase (iterator position);C++11
iterator erase (const_iterator position);Return value
It returns the number of elements erased.
ExceptionsIt never throws exception.
Time complexityTime complexity is constant.
ExampleThe following example shows the usage of std::set::erase.
#include <iostream> #include <set> int main () { std::set<int> myset; std::set<int>::iterator it; for (int i = 1; i < 10; i++) myset.insert(i*20); it = myset.begin(); ++it; myset.erase (it); myset.erase (80); it = myset.find (60); myset.erase (it, myset.end()); std::cout << "myset contains:"; for (it = myset.begin(); it!=myset.end(); ++it) std::cout << ' ' << *it; std::cout << '\n'; return 0; }
The above program will compile and execute properly.
myset contains: 20
set.htm
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4