常用数据结构
- vector
- list
- map
- set
- stack
- queue
- deque
- priority_queue
vector
Vectors are same as dynamic arrays with the ability to resize itself automatically when an element is inserted or deleted, with their storage being handled automatically by the container. Vector elements are placed in contiguous storage so that they can be accessed and traversed using iterators. In vectors, data is inserted at the end takes differential time, as sometimes there may be a need of extending the arry. Removing the last element takes only constant time because no resizing happens. Inserting and erasing at the beginning or in the middle is linear in time.
Vector in C++ STL
list
Lists are sequence containers that non-contiguous memory allocati

本文介绍了C++ STL中的常用数据结构,包括vector、list、map、set、stack、queue、deque和priority_queue。vector是动态数组,提供自动扩展功能;list是双链表,插入删除操作快速;map是键值对映射,元素唯一;set存储唯一元素,不可修改;stack遵循LIFO原则;queue遵循FIFO原则;deque在两端均可插入删除,效率高;priority_queue则保证元素按优先级排序。
最低0.47元/天 解锁文章
2519

被折叠的 条评论
为什么被折叠?



