为什么有人会使用 set 而不是 unordered

编程入门 行业动态 更新时间:2024-10-10 02:15:55
本文介绍了为什么有人会使用 set 而不是 unordered_set?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

C++0x 正在引入 unordered_set,它可以在 boost 和许多其他地方使用.我的理解是 unordered_set 是具有 O(1) 查找复杂性的哈希表.另一方面,set 只不过是具有 log(n) 查找复杂性的树.到底为什么有人会使用set 而不是unordered_set?即是否需要 set 了?

C++0x is introducing unordered_set which is available in boost and many other places. What I understand is that unordered_set is hash table with O(1) lookup complexity. On the other hand, set is nothing but a tree with log(n) lookup complexity. Why on earth would anyone use set instead of unordered_set? i.e is there a need for set anymore?

推荐答案

对于想要迭代集合中的项目的人来说,顺序很重要.

When, for someone who wants to iterate over the items of the set, the order matters.

更多推荐

为什么有人会使用 set 而不是 unordered

本文发布于:2023-11-29 01:48:36,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1644809.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:人会   而不是   set   unordered

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!