C++标准库__std::deque(双端队列),std::queue(队列),std::stack(栈)__由stl的定义我们就可以看出 queue和stack都是基于deque实现的和常用接口
来源:互联网 发布:mac os 升级老版本 编辑:程序博客网 时间:2024/05/22 14:16
std::deque(双端队列):
定义:
template<
class T,
class Allocator = std::allocator<T>
实现接口:
http://en.cppreference.com/w/cpp/container/deque
接口:
max_size 可以容纳的最大元素个数,为resize提供帮助,是根据成员类型和可以访问的虚拟内存的大小计算出来的。
Member functions
(constructor)
constructs the deque
(public member function)
(destructor)
destructs the deque
(public member function)
operator=
assigns values to the container (public member function)
assign
assigns values to the container (public member function)
get_allocator
returns the associated allocator (public member function)
Element access
at
access specified element with bounds checking (public member function)
operator[]
access specified element (public member function)
front
access the first element (public member function)
back
access the last element (public member function)
Iterators
begincbegin
returns an iterator to the beginning (public member function)
endcend
returns an iterator to the end (public member function)
rbegincrbegin
returns a reverse iterator to the beginning (public member function)
rendcrend
returns a reverse iterator to the end (public member function)
Capacity
empty
checks whether the container is empty (public member function)
size
returns the number of elements (public member function)
max_size
returns the maximum possible number of elements (public member function)
shrink_to_fit
(C++11)
reduces memory usage by freeing unused memory (public member function)
Modifiers
clear
clears the contents (public member function)
insert
inserts elements (public member function)
emplace
(C++11)
constructs element in-place (public member function)
erase
erases elements (public member function)
push_back
adds elements to the end (public member function)
emplace_back
(C++11)
constructs elements in-place at the end (public member function)
pop_back
removes the last element (public member function)
push_front
inserts elements to the beginning (public member function)
emplace_front
(C++11)
constructs elements in-place at the beginning (public member function)
pop_front
removes the first element (public member function)
resize
changes the number of elements stored (public member function)
swap
swaps the contents (public member function)
std::queue(队列):
定义:
template<
class T,
class Container = std::deque<T>
实现接口:
http://en.cppreference.com/w/cpp/container/queue
queue的三个主要操作接口:
push <--> 调用deque的push_back来实现;
pop <--> 调用deque的pop_front来实现;
front <--> 调用deque的front来实现;
back <--> 调用deque的back来实现;
Member functions
(constructor)
constructs the queue
(public member function)
(destructor)
destructs the queue
(public member function)
operator=
assigns values to the container adaptor (public member function)
Element access
front
access the first element (public member function)
back
access the last element (public member function)
Capacity
empty
checks whether the underlying container is empty (public member function)
size
returns the number of elements (public member function)
Modifiers
push
inserts element at the end (public member function)
emplace
(C++11)
constructs element in-place at the end (public member function)
pop
removes the first element (public member function)
swap
swaps the contents (public member function)
std::stack(栈):
定义:
template<
class T,
class Container = std::deque<T>
实现接口:
http://en.cppreference.com/w/cpp/container/stack
栈的三个主要操作接口:
push <--> 调用deque的push_back来实现;
pop <--> 调用deque的pop_back实现;
top <--> 调用deque的back实现;
Member functions
(constructor)
constructs the queue
(public member function)
(destructor)
destructs the queue
(public member function)
operator=
assigns values to the container adaptor (public member function)
Element access
front
access the first element (public member function)
back
access the last element (public member function)
Capacity
empty
checks whether the underlying container is empty (public member function)
size
returns the number of elements (public member function)
Modifiers
push
inserts element at the end (public member function)
emplace
(C++11)
constructs element in-place at the end (public member function)
pop
removes the first element (public member function)
swap
swaps the contents (public member function)
由定义我们就可以看出 queue和stack都是基于deque实现的!
0 0
- C++标准库__std::deque(双端队列),std::queue(队列),std::stack(栈)__由stl的定义我们就可以看出 queue和stack都是基于deque实现的和常用接口
- Queue、Deque和Stack
- 【双端队列】【栈】【队列】STL之deque、stack、queue、容器适配器
- 队列的Queue接口和Deque接口的方法概述
- STL之queue队列 stack栈 priority_queue优先队列 deque双向队列
- stack、queue、deque的区别
- stack,deque,queue的区别
- 栈stack和队列queue的常用基本函数
- Java Queue 和 Deque队列
- 栈Stack和队列Queue
- 栈Stack和队列Queue
- python实现stack(栈)和队列(queue)
- Java实现栈Stack和队列Queue
- STL中deque,queue,stack,list的学习
- C++11:基于std::queue和std::mutex构建一个线程安全的队列
- STL容器--顺序容器-队列queue和deque
- stack,deque,queue对比
- stack,deque,queue对照
- 《私房菜》3rd 笔记1. 基础命令
- oracle 五
- Swift中用NSURLConnection解析URL,并解析Jason数据
- oracle 六
- visual C++使用ADO访问sql server 2000
- C++标准库__std::deque(双端队列),std::queue(队列),std::stack(栈)__由stl的定义我们就可以看出 queue和stack都是基于deque实现的和常用接口
- Android安全机制
- uva10069
- oracle 七
- try {}里有一个return语句,那么紧跟在这个try后的finally {}里的code会不会被执行,什么时候被执行,在return前还是后?
- dp HDU 1421
- Cheap Ugg Boots Discount Code ylddl yixf13
- Wireshark 教程
- Cheap Ugg Boots Primark stfnb tbyn27