首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

std::queue

Defined in header <queue>

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::dequestd::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<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<std::queue> (C++11)

specializes the std::uses_allocator type trait (function template)

代码语言:txt
复制
 © cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

扫码关注腾讯云开发者

领取腾讯云代金券