在C ++中,是std :: string :: push_back()O(1)的摊销复杂度? [英] In C++, is the amortized complexity of std::string::push_back() O(1)?

查看:770
本文介绍了在C ++中,是std :: string :: push_back()O(1)的摊销复杂度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道标准指定它是向量,但是字符串呢?

I know the standard specifies that it is for vectors, but what about strings?

推荐答案

时间。请参阅第716页的表101 本文档

Yes, it is amortized constant time. See table 101 on page 716 of this document:


表101列出了为某些类型的序列容器而不是其他类型提供的操作。
实现应为容器列中所示的所有容器类型提供这些操作,并应实现它们以便采用经过摊销的常量时间。

Table 101 lists operations that are provided for some types of sequence containers but not others. An implementation shall provide these operations for all container types shown in the "container" column, and shall implement them so as to take amortized constant time.



Operation      | Description          | Container
---------------+----------------------+----------------------------------
a.push_back(t) | Appends a copy of t. | basic_string, deque, list, vector

这篇关于在C ++中,是std :: string :: push_back()O(1)的摊销复杂度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆