您的位置:首页 > 其它

STL_map——map::size

2014-07-20 23:00 239 查看
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.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: