<tfoot id='qwxnK'></tfoot>

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

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

      <legend id='qwxnK'><style id='qwxnK'><dir id='qwxnK'><q id='qwxnK'></q></dir></style></legend>
    2. 根据 C++ 规范,std::set 迭代顺序是否总是升序?

      Is the std::set iteration order always ascending according to the C++ specification?(根据 C++ 规范,std::set 迭代顺序是否总是升序?)
      <tfoot id='JXYZF'></tfoot>
        • <bdo id='JXYZF'></bdo><ul id='JXYZF'></ul>

            <tbody id='JXYZF'></tbody>
        • <legend id='JXYZF'><style id='JXYZF'><dir id='JXYZF'><q id='JXYZF'></q></dir></style></legend>

              <i id='JXYZF'><tr id='JXYZF'><dt id='JXYZF'><q id='JXYZF'><span id='JXYZF'><b id='JXYZF'><form id='JXYZF'><ins id='JXYZF'></ins><ul id='JXYZF'></ul><sub id='JXYZF'></sub></form><legend id='JXYZF'></legend><bdo id='JXYZF'><pre id='JXYZF'><center id='JXYZF'></center></pre></bdo></b><th id='JXYZF'></th></span></q></dt></tr></i><div id='JXYZF'><tfoot id='JXYZF'></tfoot><dl id='JXYZF'><fieldset id='JXYZF'></fieldset></dl></div>

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

                本文介绍了根据 C++ 规范,std::set 迭代顺序是否总是升序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                这里 http://www.cplusplus.com/reference/stl/set/ 我读到了C++ 中的 std::set 通常"被实现为一棵树(红黑树?)并且它被排序.

                Here http://www.cplusplus.com/reference/stl/set/ I read that std::set in C++ is "typically" implemented as a tree (red-black one?) and it is sorted.

                我不明白,这是否意味着按规范集合的迭代顺序总是升序?还是只是通常的实现细节",有时某些库/编译器可能会违反此约定?

                I could not understand, does it mean that by specification iteration order of set is always ascending? Or is it only "usual implementation detail" and sometimes, some library/compiler may violate this convention?

                推荐答案

                根据 C++ 标准,对 std::set 中元素的迭代按照 std 确定的排序顺序进行::less 或通过可选的比较谓词模板参数.

                Per the C++ standard, iteration over the elements in an std::set proceeds in sorted order as determined by std::less or by the optional comparison predicate template argument.

                (同样按照 C++ 标准,插入、查找和删除最多需要 O(lg n) 时间,所以平衡搜索树是目前 std 唯一可行的实现选择:设置,即使标准没有强制要求使用红黑树.)

                (Also per the C++ standard, insertion, lookup and deletion take at most O(lg n) time, so balanced search trees are currently the only viable implementation choice for std::set, even though the use of red-black trees is not mandated by the standard.)

                这篇关于根据 C++ 规范,std::set 迭代顺序是否总是升序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                相关文档推荐

                What is the past-the-end iterator in STL C++?(STL C++ 中的最后迭代器是什么?)
                vector::at vs. vector::operator[](vector::at 与 vector::operator[])
                C++ equivalent of StringBuffer/StringBuilder?(C++ 等效于 StringBuffer/StringBuilder?)
                Adding types to the std namespace(将类型添加到 std 命名空间)
                Is the C++ std::set thread-safe?(C++ std::set 线程安全吗?)
                How to use std::find/std::find_if with a vector of custom class objects?(如何将 std::find/std::find_if 与自定义类对象的向量一起使用?)

                • <bdo id='NKJRR'></bdo><ul id='NKJRR'></ul>
                          <tbody id='NKJRR'></tbody>

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

                          <tfoot id='NKJRR'></tfoot>
                          <i id='NKJRR'><tr id='NKJRR'><dt id='NKJRR'><q id='NKJRR'><span id='NKJRR'><b id='NKJRR'><form id='NKJRR'><ins id='NKJRR'></ins><ul id='NKJRR'></ul><sub id='NKJRR'></sub></form><legend id='NKJRR'></legend><bdo id='NKJRR'><pre id='NKJRR'><center id='NKJRR'></center></pre></bdo></b><th id='NKJRR'></th></span></q></dt></tr></i><div id='NKJRR'><tfoot id='NKJRR'></tfoot><dl id='NKJRR'><fieldset id='NKJRR'></fieldset></dl></div>

                          <legend id='NKJRR'><style id='NKJRR'><dir id='NKJRR'><q id='NKJRR'></q></dir></style></legend>