为什么有人会使用set而不是unordered_set? [英] Why would anyone use set instead of unordered_set?
本文介绍了为什么有人会使用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_set?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文