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

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

    1. <legend id='D1fL6'><style id='D1fL6'><dir id='D1fL6'><q id='D1fL6'></q></dir></style></legend>
      • <bdo id='D1fL6'></bdo><ul id='D1fL6'></ul>

      std::string size() 是 O(1) 运算吗?

      Is std::string size() a O(1) operation?(std::string size() 是 O(1) 运算吗?)

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

          <tbody id='wSaVO'></tbody>

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

            <tfoot id='wSaVO'></tfoot>
            <legend id='wSaVO'><style id='wSaVO'><dir id='wSaVO'><q id='wSaVO'></q></dir></style></legend>
              1. 本文介绍了std::string size() 是 O(1) 运算吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                std::string size() 是 O(1) 运算吗?

                Is std::string size() a O(1) operation?

                我使用的STL实现是VC++自带的

                The implementation of STL I'm using is the one built into VC++

                推荐答案

                如果您问 MSVC 的 string::size() 实现是否具有恒定复杂性,那么答案是肯定的.但是 Don Wakefield 提到了 C++ 标准 23.1 中的表 65说 size() 的复杂性应该遵循注释 A"中所说的.注释 A 说:

                If you're asking if MSVC's implementation of string::size() has constant complexity, then the answer is yes. But Don Wakefield mentioned Table 65 in 23.1 of the C++ Standard where it says that the complexity of size() should follow what's said in 'Note A'. Note A says:

                那些标记为(注 A)"的条目应该具有恒定的复杂性.

                Those entries marked ‘‘(Note A)’’ should have constant complexity.

                然而,这并不意味着这些条目应该具有恒定的复杂性.标准使用非常具体的术语,应该"意味着它不是强制性的.

                However, that does not mean that those entries shall have constant complexity. Standards use very specific terminology, and "should" means that it is not mandatory.

                'Note A' 被添加到标准中是为了安抚那些认为应该允许 size() 具有线性复杂性的人修改.

                'Note A' was added to the standard specifically to appease those who believed that size() should be allowed to have linear complexity so it would not be necessary to keep the size when the containers were modified.

                所以你不能依赖 size() 具有恒定的复杂性,但老实说,我不确定是否有任何实现没有恒定的 string::size().

                So you can't rely on size() having constant complexity, but I'm honestly not sure if there are any implementations that do not have a constant string::size().

                这篇关于std::string size() 是 O(1) 运算吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                相关文档推荐

                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++ 中生成随机数的最佳方法是什么?)

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

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