gpt4 book ai didi

c++11 - unordered_set find 方法的时间复杂度

转载 作者:行者123 更新时间:2023-12-04 03:14:19 31 4
gpt4 key购买 nike

find 的时间复杂度是多少? unordered_set<int> 中的方法?

并且是否可以更改哈希函数?

最佳答案

what is the time complexity of find method in unordered_set?



...它就在您链接的页面中:

Complexity:

Average case: constant.

Worst case: linear in container size.



and also it it possible to change the hash functions?



是的。再看 at the documentation !
std::unordered_map需要 Hash模板参数。这是一个自定义点,您可以在其中注入(inject)自己的哈希逻辑。定制 Hash必须满足 Hash 概念。

关于c++11 - unordered_set<int> find 方法的时间复杂度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42487673/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com