<tfoot id='LgPyh'></tfoot>

<small id='LgPyh'></small><noframes id='LgPyh'>

      • <bdo id='LgPyh'></bdo><ul id='LgPyh'></ul>

      1. <legend id='LgPyh'><style id='LgPyh'><dir id='LgPyh'><q id='LgPyh'></q></dir></style></legend>
      2. <i id='LgPyh'><tr id='LgPyh'><dt id='LgPyh'><q id='LgPyh'><span id='LgPyh'><b id='LgPyh'><form id='LgPyh'><ins id='LgPyh'></ins><ul id='LgPyh'></ul><sub id='LgPyh'></sub></form><legend id='LgPyh'></legend><bdo id='LgPyh'><pre id='LgPyh'><center id='LgPyh'></center></pre></bdo></b><th id='LgPyh'></th></span></q></dt></tr></i><div id='LgPyh'><tfoot id='LgPyh'></tfoot><dl id='LgPyh'><fieldset id='LgPyh'></fieldset></dl></div>

        std::vector 与 std::list 与 std::slist 的相对性能?

        Relative performance of std::vector vs. std::list vs. std::slist?(std::vector 与 std::list 与 std::slist 的相对性能?)
        <i id='AeQnC'><tr id='AeQnC'><dt id='AeQnC'><q id='AeQnC'><span id='AeQnC'><b id='AeQnC'><form id='AeQnC'><ins id='AeQnC'></ins><ul id='AeQnC'></ul><sub id='AeQnC'></sub></form><legend id='AeQnC'></legend><bdo id='AeQnC'><pre id='AeQnC'><center id='AeQnC'></center></pre></bdo></b><th id='AeQnC'></th></span></q></dt></tr></i><div id='AeQnC'><tfoot id='AeQnC'></tfoot><dl id='AeQnC'><fieldset id='AeQnC'></fieldset></dl></div>
        <tfoot id='AeQnC'></tfoot>

      3. <small id='AeQnC'></small><noframes id='AeQnC'>

            • <bdo id='AeQnC'></bdo><ul id='AeQnC'></ul>
                <legend id='AeQnC'><style id='AeQnC'><dir id='AeQnC'><q id='AeQnC'></q></dir></style></legend>
                  <tbody id='AeQnC'></tbody>

                • 本文介绍了std::vector 与 std::list 与 std::slist 的相对性能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  对于不需要随机访问列表元素的简单链表,使用 std::list 代替 std 是否有任何显着优势(性能或其他)::vector?如果需要向后遍历,在遍历列表元素之前使用 std::slistreverse() 会更有效吗?

                  For a simple linked list in which random access to list elements is not a requirement, are there any significant advantages (performance or otherwise) to using std::list instead of std::vector? If backwards traversal is required, would it be more efficient to use std::slist and reverse() the list prior to iterating over its elements?

                  推荐答案

                  像往常一样,性能问题的最佳答案是 profile 适用于您的用例的两种实现,看看哪个更快.

                  As usual the best answer to performance questions is to profile both implementations for your use case and see which is faster.

                  一般来说,如果你有插入数据结构(不是在最后)那么 vector 可能会更慢,否则在大多数情况下 vector 预计会执行如果仅针对 数据局部性问题,则比 list 更好,这意味着如果数据集中相邻的两个元素在内存中相邻,那么下一个元素将已经在处理器的缓存中,并且不必将内存页错误到缓存中.

                  In general if you have insertions into the data-structure (other than at the end) then vector may be slower, otherwise in most cases vector is expected to perform better than list if only for data locality issues, this means that if two elements that are adjacent in the data-set are adjacent in memory then the next element will already be in the processor's cache and will not have to page fault the memory into the cache.

                  还要记住,vector 的空间开销是恒定的(3 个指针),而 list 的空间开销是为每个元素支付的,这也减少了任意时刻可以驻留在缓存中的完整元素(数据加上开销)的数量.

                  Also keep in mind that the space overhead for a vector is constant (3 pointers) while the space overhead for a list is paid for each element, this also reduces the number of full elements (data plus overhead) that can reside in the cache at any one time.

                  这篇关于std::vector 与 std::list 与 std::slist 的相对性能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Consistent pseudo-random numbers across platforms(跨平台一致的伪随机数)
                  Vary range of uniform_int_distribution(改变uniform_int_distribution的范围)
                  What is a seed in terms of generating a random number?(就生成随机数而言,种子是什么?)
                  Is 1.0 a valid output from std::generate_canonical?(1.0 是 std::generate_canonical 的有效输出吗?)
                  Getting big random numbers in C/C++(在 C/C++ 中获取大随机数)
                  What is the best way to generate random numbers in C++?(在 C++ 中生成随机数的最佳方法是什么?)
                    <tbody id='X2sui'></tbody>
                    <bdo id='X2sui'></bdo><ul id='X2sui'></ul>
                    <i id='X2sui'><tr id='X2sui'><dt id='X2sui'><q id='X2sui'><span id='X2sui'><b id='X2sui'><form id='X2sui'><ins id='X2sui'></ins><ul id='X2sui'></ul><sub id='X2sui'></sub></form><legend id='X2sui'></legend><bdo id='X2sui'><pre id='X2sui'><center id='X2sui'></center></pre></bdo></b><th id='X2sui'></th></span></q></dt></tr></i><div id='X2sui'><tfoot id='X2sui'></tfoot><dl id='X2sui'><fieldset id='X2sui'></fieldset></dl></div>
                    <legend id='X2sui'><style id='X2sui'><dir id='X2sui'><q id='X2sui'></q></dir></style></legend>
                    <tfoot id='X2sui'></tfoot>

                    <small id='X2sui'></small><noframes id='X2sui'>