在哪里可以找到不同 STL 容器复杂性(性能)的比较?
我在谷歌上搜索了很长一段时间,以便找到一个比较,以显示所有 STL 容器在插入/推擦除/弹出等方面的复杂性差异。我没有找到任何结果。 我所有的 STL 书中也没有。 有什么提示吗?
我当然知道一些经验法则。 但定义在哪里呢?
I googled quite a while in order to find out a comparison that shows the differences in complexity for all STL-Containers on insert/push erase/pop etc. I did not find any. Also not in all of my STL Books. Any hint?
I know some rules of thumb of course. But where is a definition?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
尝试使用
http://www.sgi.com/tech/stl/complexity.html< /a>
http://www.sgi.com/tech/stl/table_of_contents.html
来自complexity.html:
Try with
http://www.sgi.com/tech/stl/complexity.html
http://www.sgi.com/tech/stl/table_of_contents.html
From complexity.html:
ISO C++ 标准根据需要定义了算法和容器访问方法的复杂性。 在其他任何地方(如果没有明确说明),所有的赌注都会被取消,库实现者可以自由地进行自己的实现。
例如,您可以假设映射和集合是使用红黑树实现的,但没有要求这样做。 许多算法被重载或专门用于特定的迭代器类别(如随机访问迭代器),有时甚至可能被优化以从特殊硬件执行(如 XMM 注册并并行执行一些操作)。
有时,由于其他要求,您确实必须逻辑地假设操作可能花费多少成本,例如 std::list 中的拼接必须具有 O(1) 复杂度 => 长度为 O(n)。
我有 N. Josuttis 的书
C++ 标准库 - 教程和参考
所有这些方面都在那里得到了很好的涵盖。
最好的问候,
奥瓦内斯
ISO C++ Standard defines the complexity of algorithms and container access methods, where required. Anywhere else (if not explicitly stated) all bets are off and a library implementor is free to do their own implementation.
For example you can assume that maps and sets are implemented using red-black trees, but there is no requirement to do so. Many algorithms are overloaded or specialized for particular iterator categories (like Random Access Iterator) and sometimes might be even optimized to perform from special hardware (like XMM register and execute some some operations in parallel).
Sometimes you really have to logically assume how much an operation might cost, due to other requirements, like splice in std::list must have O(1) complexity => length has O(n).
I have the book from N. Josuttis
C++ Standard Library - Tutorial And Reference
and all these aspects are well covered there.
Best Regards,
Ovanes
查看有关 STL、Boost 和数组容器性能的报告
http://landenlabs .com/code/perf-stl/perf-stl.html
Take a look at this report on STL, Boost and array container performance
http://landenlabs.com/code/perf-stl/perf-stl.html