读书人

可否写个小测试程序来看deque每次分配

发布时间: 2012-07-31 12:33:46 作者: rapoo

能否写个小测试程序来看deque每次分配的大小和增长程度?
如题。VC的vector可以用capacity来看push_back时候的增长速度,可以看到每次容量扩大50%

std::deque怎么看它内存分配的增长,有没有一个固定的因子?

[解决办法]
源码面前,了无秘密。

http://www.microsoft.com/visualstudio/en-us/products/2010-editions/visual-cpp-express
右边Visual C++ 2010 Express下面的Select language...下拉选‘简体中文’,再按Install Now按钮

再参考

C/C++ code
File: "C:\Program Files\Microsoft Visual Studio 10.0\VC\crt\src\vector" 2 occurrences found on 2 lines  1278:             ? 0 : _Capacity + _Capacity / 2;    // try to grow by 50%File: "C:\Program Files\Microsoft Visual Studio 10.0\VC\crt\src\deque" 1 occurrences found on 1 lines  1593:         size_type _Inc = this->_Mapsize / 2;    // try to grow by 50% 

读书人网 >C++

热点推荐