Return container size
Returns the number of elements in the container.
Parameters
none
Return Value
The number of elements that conform the
multiset's content.
Member type size_type is an unsigned integral type.
Example
// multiset::size
#include <iostream>
#include <set>
using namespace std;
int main ()
{
multiset<int> myints;
cout << "0. size: " << (int) myints.size() << endl;
for (int i=0; i<10; i++) myints.insert(i);
cout << "1. size: " << (int) myints.size() << endl;
myints.insert (5);
cout << "2. size: " << (int) myints.size() << endl;
myints.erase (5);
cout << "3. size: " << (int) myints.size() << endl;
return 0;
}
|
Output:
0. size: 0 1. size: 10 2. size: 11 3. size: 9
|
Complexity
Constant.
See also