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:
Output:
The map length is 1.
The map length is now 2.
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.
相关文章推荐
- 详细解说STL hash_map
- C++ STL标准库的关联容器set与map
- 详细解说STL hash_map系列
- STL hash_map 底层初探
- 标准模板库(STL)学习指南之map映射
- STL访问Map问题,key为Integer或Long
- STL概览-关联容器set,multiset,map,multimap
- STL 之Map (1)
- STL hash_map使用
- 标准模板库(STL)之 map 列传 (三)
- STL中map容器的一点点用法
- STL(十三)map映照容器
- C++的STL进一步总结之map
- C++中的STL中map用法详解
- STL中vector的实现原理 (衍生:Map, Set等实现原理)
- 【STL】 map
- STL 整理(map、set、vector、list、stack、queue、deque、priority_queue)
- STL中的map和multimap
- STL中map用法详解
- 利用STL中的map来写一个自己的命令行界面