[英]Time complexity of std::find() in std::unordered_set or std::unordered_map with no collisions
I know unordered_map has O(1) lookups but std::find() is a searching algorithm(I guess) in other containers.So is it O(1) or O(n) considering there is no collision.我知道 unordered_map 有 O(1) 查找,但 std::find() 是其他容器中的搜索算法(我猜)。考虑到没有冲突,它是 O(1) 还是 O(n)。
From cppreference for std::unordered_map<Key,T,Hash,KeyEqual,Allocator>::find
:来自
std::unordered_map<Key,T,Hash,KeyEqual,Allocator>::find
的cppreference :
Complexity
复杂
Constant on average, worst case linear in the size of the container.
平均恒定,最坏情况与容器大小呈线性关系。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.