免费的素材网站,温州网站建设制作,wordpress首页插件,域名升级这里写自定义目录标题 常用的C STLstackqueuedeque 常用的C STL
常用到的C STL#xff0c;方便查询。
stack
Stack是一种容器适配器#xff0c;专门设计用于LIFO (last-in first-out)操作#xff0c;仅从容器的一端插入删除元素#xff08;back or top#xff09;。
成… 这里写自定义目录标题 常用的C STLstackqueuedeque 常用的C STL
常用到的C STL方便查询。
stack
Stack是一种容器适配器专门设计用于LIFO (last-in first-out)操作仅从容器的一端插入删除元素back or top。
成员类型c98
member typedefinitionnotesvalue_typeThe first template parameter (T)Type of the elementscontainer_typeThe second template parameter (Container)Type of the underlying containersize_typean unsigned integral typeusually the same as size_t
成员函数
函数说明emptyTest whether container is emptysizeReturn sizetopAccess next elementpushInsert elementpopRemove top elementemplace(c11)Construct and insert elementswap(c11)Swap contents
queue
Queue 是一种容器适配器专门设计用于FIFO (first-in first-out) 操作从容器的一端插入从另一端元素push from back and pop from front。
成员类型c98
member typedefinitionnotesvalue_typeThe first template parameter (T)Type of the elementscontainer_typeThe second template parameter (Container)Type of the underlying containersize_typean unsigned integral typeusually the same as size_t
成员函数
函数说明emptyTest whether container is emptysizeReturn sizefrontAccess next elementbackAccess last elementpushInsert elementpopRemove next elementemplace(c11)Construct and insert elementswap(c11)Swap contents
deque
双端队列double-ended queue是具有动态大小的容器序列可以在两端前端后端扩展或收缩。 特定的库可以以不同的形式实现Deque通常是动态数组。但在任何一种实现他们都允许通过随机访问迭代器直接访问独立元素并自动按需处理容量的扩展和收缩。 因此它提供了与 vector 十分类似的功能它不仅可以末尾也可以在序列的前端插入和删除元素。但与 vectors 不同的是deques 不能保证所有元素都存储在连续的位置通过偏移指针去访问另一个元素会导致未定义的行为。 vectors 和 deque 提供了非常相似的功能但是它们内部的工作方式十分不同。vectors 使用单个数组需要偶尔重新分配以应对数据的增长deque 的元素可以被分散到不同的存储块容器保持必要的信息提供在常数时间内直接访问任何元素通过 iterators。因此deques 更复杂对于特别长的序列相对与重新分配内存deques 能更加有效的增长。
成员类型
member typedefinitionnotesvalue_typeThe first template parameter (T)Type of the elementsallocator_typeThe second template parameter (Alloc)defaults to: allocatorvalue_typereferenceallocator_type::referencefor the default allocator: value_typeconst_referenceallocator_type::const_referencefor the default allocator: const value_typepointerallocator_type::pointerfor the default allocator: value_type*const_pointerallocator_type::const_pointerfor the default allocator: const value_type*iteratora random access iterator to value_typeconvertible to const_iteratorconst_iteratora random access iterator to const value_typereverse_iteratorreverse_iteratorconst_reverse_iteratorreverse_iteratorconst_iteratordifference_typea signed integral type, identical to: iterator_traits::difference_typeusually the same as ptrdiff_tsize_typean unsigned integral type that can represent any non-negative value of difference_typeusually the same as size_t
成员函数
函数说明emptyTest whether container is emptysizeReturn sizemax_sizeReturn maximum sizeresizeChange sizeshrink_to_fit(c11)Shrink to fitassignAssign container contentpush_backAdd element at the endpush_frontInsert element at beginningpop_backDelete last elementpop_frontDelete first elementinsertInsert elementseraseErase elementsswapSwap contentclearClear contentemplace(c11)Construct and insert elementemplace_front(c11)Construct and insert element at beginningemplace_back(c11)Construct and insert element at the end