It returns the number of elements in the set container.
DeclarationFollowing are the ways in which std::set::size works in various C++ versions.
C++98size_type size() const;C++11
size_type size() const noexcept;;Return value
It returns the number of elements in the set container.
ExceptionsIt never throws exceptions.
Time complexityTime complexity is contstant.
ExampleThe following example shows the usage of std::set::size.
#include <iostream> #include <set> int main () { std::set<int> myints; std::cout << "0. size: " << myints.size() << '\n'; for (int i = 0; i < 5; ++i) myints.insert(i); std::cout << "1. size: " << myints.size() << '\n'; myints.insert (200); std::cout << "2. size: " << myints.size() << '\n'; myints.erase(10); std::cout << "3. size: " << myints.size() << '\n'; return 0; }
The above program will compile and execute properly.
0. size: 0 1. size: 5 2. size: 6 3. size: 6
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