public member function

std::multiset::size

<set>
size_type size() const;
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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// 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