STL basic container: is string, vector, list, deque, set, map_string[] ordered?_cy941228’s blog

class=”markdown_views prism-atom-one-dark”> Basic containers in STL are: string, vector, list, deque, set, map set and map are unordered storage elements, which can only be accessed through the interface it provides set: collection, used to judge whether an element is in a group, less used map: mapping, equivalent to a dictionary, mapping one value to another value, if you want to create a dictionary, use it’s alright string, vector, list, deque, set are ordered containers 1.string string is the implementation of basic_string, and it is stored continuously in memory. In order to improve efficiency, there will be reserved memory, such as string s= “abcd”, then the space used by s may be 255, when string is inserted into s again When adding content, memory will not be allocated again. It will not apply for memory again until the content is > 255, thus improving its performance. When the content is > 255, string will first allocate a new memory, and then copy the content over , and then copy the previous content. The operation on string, if it is added to the end, generally does not need to allocate memory, so the performance is the fastest; If it is an operation…

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索