std::unordered_set 或 std::unordered_map 中 std::find() 的时间复杂度,无冲突

Time complexity of std::find() in std::unordered_set or std::unordered_map with no collisions

我知道 unordered_map 有 O(1) 次查找,但 std::find() 是一种搜索算法(我猜)在其他 containers.So 中是 O(1) 还是 O( n) 考虑到没有碰撞。

来自 cppreference std::unordered_map<Key,T,Hash,KeyEqual,Allocator>::find:

Complexity

Constant on average, worst case linear in the size of the container.