STL_map——map::size

来源:互联网 发布:linux wput 编辑:程序博客网 时间:2024/06/04 22:47
Reference:
Returns the number of elements in the map.

Function:
size_type size( ) const;

Return Value:
The current length of the map.

Example:
#include <map>#include <iostream>int main( ){   using namespace std;      map <int, int> m1, m2;   int i;   typedef pair <int, int> Int_Pair;   m1.insert ( Int_Pair ( 1, 1 ) );   i = m1.size( );   cout << "The map length is " << i << "." << endl;   m1.insert ( Int_Pair ( 2, 4 ) );   i = m1.size( );   cout << "The map length is now " << i << "." << endl;}

Output:
The map length is 1.
The map length is now 2.
0 0
原创粉丝点击