该程序演示了map在形成的时候对内存的操作和分配。
因为自己对平衡二叉树的创建细节理解不够,还不太明白程序所显示的日志。等我明白了,再来修改这个文档。
/*
功能说明:
map的内存分配机制分析。
代码说明:
map所管理的内存地址可以是不连续的。如果key是可以通过<排序的,那么,map最后的结果是有序的。它是通过一个平衡二叉树来保存数据。所以,其查找效率极高。
实现方式:
限制条件或者存在的问题:
无
*/
#include
#include
#include
程序的输出结果:
process begin at 00C917FD
CData(int i,string &s) [sequence:1 | remark:baby_test] 0053F6F0
CData(int i,string &s) [sequence:2 | remark:baby_test] 0053F6C8
CData(int i,string &s) [sequence:3 | remark:baby_test] 0053F6A0
CData(int i,string &s) [sequence:4 | remark:baby_test] 0053F678
CData(int i,string &s) [sequence:5 | remark:baby_test] 0053F650
CData(int i,string &s) [sequence:6 | remark:baby_test] 0053F628
CData(int i,string &s) [sequence:7 | remark:baby_test] 0053F600
CData(int i,string &s) [sequence:8 | remark:baby_test] 0053F5D8
CData(int i,string &s) [sequence:9 | remark:baby_test] 0053F5B0
CData(int i,string &s) [sequence:10 | remark:baby_test] 0053F588
push CData to map
max size of list
is 82595524
size of list is 0
****************map_data.push_back(data1)
CData(const CData &data) [sequence:1 | remark:baby_test] 0053F158
CData(const CData &data) [sequence:1 | remark:baby_test] 005F6F74
~CData() 0053F158
****************map_data.push_back(data2)
CData(const CData &data) [sequence:2 | remark:baby_test] 0053F108
CData(const CData &data) [sequence:2 | remark:baby_test] 005FE2A4
~CData() 0053F108
****************map_data.push_back(data3)
CData(const CData &data) [sequence:3 | remark:baby_test] 0053F0B8
CData(const CData &data) [sequence:3 | remark:baby_test] 005FE304
~CData() 0053F0B8
****************map_data.push_back(data4)
CData(const CData &data) [sequence:4 | remark:baby_test] 0053F068
CData(const CData &data) [sequence:4 | remark:baby_test] 005FE364
~CData() 0053F068
****************map_data.push_back(data5)
CData(const CData &data) [sequence:5 | remark:baby_test] 0053F018
CData(const CData &data) [sequence:5 | remark:baby_test] 005FE3C4
~CData() 0053F018
****************map_data.push_back(data6)
CData(const CData &data) [sequence:6 | remark:baby_test] 0053EFC8
CData(const CData &data) [sequence:6 | remark:baby_test] 005FE424
~CData() 0053EFC8
****************map_data.push_back(data7)
CData(const CData &data) [sequence:7 | remark:baby_test] 0053EF78
CData(const CData &data) [sequence:7 | remark:baby_test] 005FE484
~CData() 0053EF78
****************map_data.push_back(data8)
CData(const CData &data) [sequence:8 | remark:baby_test] 0053EF28
CData(const CData &data) [sequence:8 | remark:baby_test] 005FE4E4
~CData() 0053EF28
****************map_data.push_back(data9)
CData(const CData &data) [sequence:9 | remark:baby_test] 0053EED8
CData(const CData &data) [sequence:9 | remark:baby_test] 005FED9C
~CData() 0053EED8
****************map_data.push_back(data10)
CData(const CData &data) [sequence:10 | remark:baby_test] 0053EE88
CData(const CData &data) [sequence:10 | remark:baby_test] 005FEDFC
~CData() 0053EE88
===============show map by iterator
key:1 value:address of itr is 005F6F74 and msg is [sequence:1 | remark:baby_test]
key:2 value:address of itr is 005FE2A4 and msg is [sequence:2 | remark:baby_test]
key:3 value:address of itr is 005FE304 and msg is [sequence:3 | remark:baby_test]
key:4 value:address of itr is 005FE364 and msg is [sequence:4 | remark:baby_test]
key:5 value:address of itr is 005FE3C4 and msg is [sequence:5 | remark:baby_test]
key:6 value:address of itr is 005FE424 and msg is [sequence:6 | remark:baby_test]
key:7 value:address of itr is 005FE484 and msg is [sequence:7 | remark:baby_test]
key:8 value:address of itr is 005FE4E4 and msg is [sequence:8 | remark:baby_test]
key:9 value:address of itr is 005FED9C and msg is [sequence:9 | remark:baby_test]
key:10 value:address of itr is 005FEDFC and msg is [sequence:10 | remark:baby_test]
===============clear map 1
~CData() 005FEDFC
~CData() 005FED9C
~CData() 005FE4E4
~CData() 005FE484
~CData() 005FE424
~CData() 005FE3C4
~CData() 005FE364
~CData() 005FE304
~CData() 005FE2A4
~CData() 005F6F74
****************map_data.push_back(data6)
CData(const CData &data) [sequence:6 | remark:baby_test] 0053EDE0
CData(const CData &data) [sequence:6 | remark:baby_test] 005F6F74
~CData() 0053EDE0
****************map_data.push_back(data2)
CData(const CData &data) [sequence:2 | remark:baby_test] 0053ED90
CData(const CData &data) [sequence:2 | remark:baby_test] 005FED9C
~CData() 0053ED90
****************map_data.push_back(data3)
CData(const CData &data) [sequence:3 | remark:baby_test] 0053ED40
CData(const CData &data) [sequence:3 | remark:baby_test] 005FEDFC
~CData() 0053ED40
****************map_data.push_back(data1
CData(const CData &data) [sequence:1 | remark:baby_test] 0053ECF0
CData(const CData &data) [sequence:1 | remark:baby_test] 005FEE5C
~CData() 0053ECF0
****************map_data.push_back(data10)
CData(const CData &data) [sequence:10 | remark:baby_test] 0053ECA0
CData(const CData &data) [sequence:10 | remark:baby_test] 005FEEBC
~CData() 0053ECA0
****************map_data.push_back(data4)
CData(const CData &data) [sequence:4 | remark:baby_test] 0053EC50
CData(const CData &data) [sequence:4 | remark:baby_test] 005FEF1C
~CData() 0053EC50
****************map_data.push_back(data7)
CData(const CData &data) [sequence:7 | remark:baby_test] 0053EC00
CData(const CData &data) [sequence:7 | remark:baby_test] 005FEF7C
~CData() 0053EC00
****************map_data.push_back(data8)
CData(const CData &data) [sequence:8 | remark:baby_test] 0053EBB0
CData(const CData &data) [sequence:8 | remark:baby_test] 005FE2A4
~CData() 0053EBB0
****************map_data.push_back(data9)
CData(const CData &data) [sequence:9 | remark:baby_test] 0053EB60
CData(const CData &data) [sequence:9 | remark:baby_test] 005FE304
~CData() 0053EB60
****************map_data.push_back(data5)
CData(const CData &data) [sequence:5 | remark:baby_test] 0053EB10
CData(const CData &data) [sequence:5 | remark:baby_test] 005FE364
~CData() 0053EB10
===============show map by iterator 2
key:1 value:address of itr is 005FEE5C and msg is [sequence:1 | remark:baby_test]
key:2 value:address of itr is 005FED9C and msg is [sequence:2 | remark:baby_test]
key:3 value:address of itr is 005FEDFC and msg is [sequence:3 | remark:baby_test]
key:4 value:address of itr is 005FEF1C and msg is [sequence:4 | remark:baby_test]
key:5 value:address of itr is 005FE364 and msg is [sequence:5 | remark:baby_test]
key:6 value:address of itr is 005F6F74 and msg is [sequence:6 | remark:baby_test]
key:7 value:address of itr is 005FEF7C and msg is [sequence:7 | remark:baby_test]
key:8 value:address of itr is 005FE2A4 and msg is [sequence:8 | remark:baby_test]
key:9 value:address of itr is 005FE304 and msg is [sequence:9 | remark:baby_test]
key:10 value:address of itr is 005FEEBC and msg is [sequence:10 | remark:baby_test]
===============clear map 2
~CData() 005FEEBC
~CData() 005FE304
~CData() 005FE2A4
~CData() 005FEF7C
~CData() 005F6F74
~CData() 005FE364
~CData() 005FEF1C
~CData() 005FEDFC
~CData() 005FED9C
~CData() 005FEE5C
======================end of process
~CData() 0053F588
~CData() 0053F5B0
~CData() 0053F5D8
~CData() 0053F600
~CData() 0053F628
~CData() 0053F650
~CData() 0053F678
~CData() 0053F6A0
~CData() 0053F6C8
~CData() 0053F6F0