std::queue
STD:排队
Defined in header | | |
---|---|---|
template< class T, class Container = std::deque<T> > class queue; | | |
大std::queue
类是一个容器适配器,它为程序员提供了队列的功能--特别是FIFO%28先进,先进先出%29数据结构。
类模板充当底层容器的包装器--只提供一组特定的函数。队列将元素推送到底层容器的后面,并从前面弹出它们。
模板参数
T | - | The type of the stored elements. The behavior is undefined if T is not the same type as Container::value_type. (since C++17) |
---|---|---|
Container | - | The type of the underlying container to use to store the elements. The container must satisfy the requirements of SequenceContainer. Additionally, it must provide the following functions with the usual semantics: back() front() push_back() pop_front() The standard containers std::deque and std::list satisfy these requirements. |
back()
front()
push_back()
pop_front()
标准容器std::deque
和std::list
满足这些要求。
成员类型
Member type | Definition |
---|---|
container_type | Container |
value_type | Container::value_type |
size_type | Container::size_type |
reference | Container::reference |
const_reference | Container::const_reference |
成员函数
(constructor) | constructs the queue (public member function) |
---|---|
(destructor) | destructs the queue (public member function) |
operator= | assigns values to the container adaptor (public member function) |
元素存取
前端访问第一个元素%28公共成员函数%29
返回访问最后一个元素%28公共成员函数%29
容量
空检查基础容器是否为空%28公共成员函数%29
Size返回元素数%28公共成员函数%29
修饰符
推插入元素在末尾%28公共成员函数%29
在末尾插入%28C++11%29构造元素在末尾%28公共成员函数%29
POP删除第一个元素%28公共成员函数%29
交换交换内容%28公共成员函数%29
成员对象
容器c底层容器%28受保护成员对象%29
非会员职能
operator==operator!=operator | lexicographically compares the values in the queue (function template) |
---|---|
std::swap(std::queue) | specializes the std::swap algorithm (function template) |
帮助者类
std::uses_allocator | specializes the std::uses_allocator type trait (function template) |
---|
© cppreference.com
在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。