想知道vector<bool>有多坑人吗
来源:互联网 发布:python split 个数 编辑:程序博客网 时间:2024/04/28 03:58
跑一下下面的程序,看看vector<bool>的表现吧
void TestVectorBool(){vector<bool> vecbool;vector<char> vecchar;const size_t vecsize = 0x03200000;for(size_t i = 0; i < vecsize; i++){vecbool.push_back(true);vecchar.push_back(1);}DWORD start = timeGetTime();size_t count = 0;for(size_t i = 0; i < vecsize; i++){if(vecbool[i])count += vecbool[i];}printf("count=%u, %ums\n",count, timeGetTime() - start);count = 0;start = timeGetTime();for(size_t i = 0; i < vecsize; i++){if(vecchar[i])count += vecchar[i];}printf("count=%d, %ums\n", count, timeGetTime() - start);return;}不过也还好,在我的电脑上执行0x03200000次,速度差5倍,相比节约内存8倍来比,还是可以接受的。
- 想知道vector<bool>有多坑人吗
- PHP file_exists有多'坑人'
- vector bool
- vector<bool>
- 大家想知道精神病鉴定有哪些方法吗
- 不用vector<bool>
- 避免使用vector<bool>
- 说一说vector<bool>
- 说一说vector<bool>
- 避免使用vector<bool>
- 避免使用vector<bool>
- STL hash<vector<bool>>
- STL vector<bool>总结
- 不要使用vector<bool>
- vector<bool>的学习
- 避免使用vector<bool>
- 避免使用vector<bool>
- std::vector<bool>
- UIScrollView的基本用法和简单示例
- 你必须十分努力,才会看起来毫不费力
- 结合MongoDB开发LBS应用
- Q2011
- Collection , List , Set 和 Map 用法和区别
- 想知道vector<bool>有多坑人吗
- 日志审计
- Tomcat连接线程超出
- hadoop2.2.0 搭建
- 个性化推荐 简单介绍(协同过滤 入门)
- 如何使用JS等比例改变显示图片的大小
- 一种高效无锁内存队列的实现
- Java 基本数据类型与byte数组互转
- 插入排序的递归写法