STL_set——set::size

来源:互联网 发布:python 字典 append 编辑:程序博客网 时间:2024/06/05 08:23
Reference:
Returns the number of elements in the set.

Function:
size_type size( ) const;

Return Value:
The current length of the set.

Example:
#include <set>#include <iostream>int main( ){   using namespace std;   set <int> s1;   set <int> :: size_type i;      s1.insert( 1 );   i = s1.size( );   cout << "The set length is " << i << "." << endl;   s1.insert( 2 );   i = s1.size( );   cout << "The set length is now " << i << "." << endl;}

Output:
The set length is 1.
The set length is now 2.
0 0