欢迎您来到芯片的主页!

Welcome to Chipset's homepage!

双数组哈希unordered_xxx

简单的类层次结构
以静态表unorered_set为例,工作原理见下图


简单的效率测试

Sample是本处讲述的双数组unordered_xxx,standard是编译器的unordered_xxx,boost1.50表示它的unordered_xxx

测试环境:

Win7 x64 Ultimate (Kernel 6.1.7601), g++4.6.3 64bit (-O3), Intel Xeon E31230 3.2GHz, Hynix DDR3-1333 ECC DIMM 4GBx2 Dual Chanel, P8B-X (Intel Cougar Point C202), WD5000AADS-00M2B0, AMI BIOS 12/26/2011, Sapphire Radeon HD 5750 GDDR5 1GB, Samsung SyncMaster BX2250(H) (Digital) 1920x1080@60Hz

测试结果:

静态表

unordered_map (64位随机数1百万个)

unordered_multimap(32位随机数1百万个)

unordered_set(字符窜253674个单个窜长200以上)

unordered_multiset(字符窜81536个单个窜长低于20)

 

Sample

standard

boost1.50

Sample

standard

boost1.50

Sample

standard

boost1.50

Sample

standard

boost1.50

插入

ms

67.8525

180.929

212.671

50.9687

150.95

199.598

85.0928

73.3596

142.383

27.8756

18.9638

16.4688

查找

72.4412

62.884

93.388

48.6442

51.0842

87.3587

68.6096

63.8798

145.687

21.9548

10.7675

12.969

删除

168.938

179.079

289.612

126.764

164.087

285.196

135.997

66.9415

136.711

53.0243

12.6135

9.6811

内存

MB

32

40

52

24

36

52

81.2

85

85.1

9.3

9.9

10.6


动态表

unordered_map (64位随机数1百万个)

unordered_multimap(32位随机数1百万个)

unordered_set(字符窜253674个单个窜长200以上)

unordered_multiset(字符窜81536个单个窜长低于20)

 

Sample

standard

boost1.50

Sample

standard

boost1.50

Sample

standard

boost1.50

Sample

standard

boost1.50

插入

ms

129.523

270.424

262.842

92.9128

256.856

291.372

143.654

127.587

149.45

38.2729

26.3448

18.4614

查找

70.2685

61.971

94.4114

46.1028

51.017

85.9693

75.2463

66.1863

149.023

22.7871

11.7799

14.482

删除

148.089

178.864

295.409

110.26

163.184

297.173

133.305

70.1459

145.462

42.8773

13.0186

10.0248

内存

MB

32.2

40

52

24.2

36

52

82.7

85.1

85

7.8

9.5

9.6

 

Visual Studio 2012编译运行结果:

静态表

unordered_map (64位随机数1百万个)

unordered_multimap(32位随机数1百万个)

unordered_set(字符窜253674个单个窜长200以上)

unordered_multiset(字符窜81536个单个窜长低于20)

 

Sample

standard

Sample

standard

Sample

standard

Sample

standard

插入

ms

59.999

188.476

50.9861

174.008

142.694

146.148

27.3501

20.3516

查找

48.1513

78.2629

33.3826

55.69

80.589

136.024

19.8892

16.9792

删除

163.05

215.432

121.721

199.238

205.691

204.848

40.771

13.3655

内存

MB

32

60.7

24

45.4

96.5

111

5.7

10.8








动态表

unordered_map (64位随机数1百万个)

unordered_multimap(32位随机数1百万个)

unordered_set(字符窜253674个单个窜长200以上)

unordered_multiset(字符窜81536个单个窜长低于20)

 

Sample

standard

Sample

standard

Sample

standard

Sample

standard

插入

ms

118.021

273.997

91.9337

252.155

249.369

243.164

41.6276

24.7281

查找

45.8492

78.085

33.4889

58.0067

92.2518

138.624

21.8552

16.6643

删除

144.097

217.688

103.813

201.557

192.211

209.361

30.966

13.7178

内存

MB

32.5

60.7

24.7

45.4

97.6

111

5.7

8.8

编译:

尽管尽可能使用C++98的语法,但编译Sampleunordered_***代码仍然需要比较新的编译器(老编译器无能为力),例如g++4.6.3以后版本,VC++2012等。

源代码请自己根据上述原理自己实现吧,为了防止版权纠纷。


posted on 2012-08-26 16:49 Chipset 阅读(2289) 评论(6)  编辑 收藏 引用 所属分类: 算法和数据结构

Feedback

# re: 双数组哈希unordered_xxx[未登录] 2012-08-27 10:27 春秋十二月

楼主,你在哪工作呢,做什么的呢  回复  更多评论   

# re: 双数组哈希unordered_xxx[未登录] 2012-08-27 12:01 Chipset

@春秋十二月
做嵌入式。  回复  更多评论   

# re: 双数组哈希unordered_xxx 2012-10-08 18:59 website design kammanahalli

The post is very informative. It is a pleasure reading it. I have also bookmarked you for checking out new posts.
  回复  更多评论   

# re: 双数组哈希unordered_xxx 2012-10-13 13:18 bangkok holiday packages

I wanted to thank you for this special read.I have also bookmarked you for checking out new posts........
  回复  更多评论   

# re: 双数组哈希unordered_xxx 2012-10-25 17:53 web designing jayanagar

So informative things are provided here,I really happy to read this post,I was just imagine about it and you provided me the correct information I really bookmark it,for further reading,So thanks for sharing the information.
  回复  更多评论   

# re: 双数组哈希unordered_xxx 2012-12-15 03:24 flights to manila

@春秋十二月
Very informative and supporting content for those want to get latest information regarding this issue.  回复  更多评论   


只有注册用户登录后才能发表评论。
【推荐】超50万行VC++源码: 大型组态工控、电力仿真CAD与GIS源码库
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理