对于像std::set和std::map这样的数据类型,查找时间为对数时间,实现是否需要维护begin和end迭代器?访问begin和end是否意味着可能会发生对数时间的查找?
我一直认为begin和end始终在常数时间内发生,但是我在Josuttis中找不到任何证实。现在我正在处理需要非常关注性能的工作,我想确保涵盖我的所有基础知识。
谢谢
但要小心hash_map。begin()不是常量。
对于std::set
begin: 常量, end: 常量, rbegin: 常量, rend: 常量,
对于std::map
它们也都是常量。
如果您有任何疑问,请查看www.cplusplus.com。