////////////////////////////////////////
// 2018/05/01 14:22:47
// map-empty
// true if the map is empty
#include <iostream>
#include <map>
using namespace std;
int main(){
typedef map<int, int> M;
M m;
m[1] = 100;
m[3] = 200;
m[5] = 500;
cout << "values of map 'm':";
M::iterator it = m.begin();
while (it != m.end()){
cout << it->second << " ";
it++;
}
cout << endl;
cout << "size of map = " << m.size() << endl;
cout << "map 'm' is " << (m.empty() ? "" : "not ") << "empty." << endl;
m.erase(m.begin(), m.end());
cout << "After m.erase(m.begin(), m.end())" << endl;
cout << "size of map = " << m.size() << endl;
cout << "map 'm' is " << (m.empty() ? "" : "not ") << "empty." << endl;
return 0;
}
/*
OUTPUT:
values of map 'm':100 200 500
size of map = 3
map 'm' is not empty.
After m.erase(m.begin(), m.end())
size of map = 0
map 'm' is empty.
*/
map-empty
转载本文章为转载内容,我们尊重原作者对文章享有的著作权。如有内容错误或侵权问题,欢迎原作者联系我们进行内容更正或删除文章。
上一篇:map-insert
下一篇:map-erase
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
map-empty
//////////////////////...
#include ios -
empty view active和empty active区别
一、 Java基础知识1. 作用域public,,protected, private以及不写时的区别 作用域 当前类 同一package 子孙类 其他package public √  
java overloading exception hashmap collections