<tfoot id='S1Kw7'></tfoot>

  1. <small id='S1Kw7'></small><noframes id='S1Kw7'>

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

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

      时间:2023-10-06
        <bdo id='GC227'></bdo><ul id='GC227'></ul>

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

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

                本文介绍了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) 运算吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:在多线程环境中是否需要保护对 STL 容器的读取访 下一篇:初始值设定项列表不适用于 Visual Studio 2012 中的向

                相关文章

                最新文章

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

                1. <legend id='R5x7x'><style id='R5x7x'><dir id='R5x7x'><q id='R5x7x'></q></dir></style></legend>

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

                2. <tfoot id='R5x7x'></tfoot>