|
| | queue ()=default |
| | 默认构造函数
|
| | queue (const Sequence &other) |
| | 构造函数,使用指定的底层容器副本
|
| | queue (Sequence &&other) noexcept(is_nothrow_move_constructible_v< Sequence >) |
| | 移动构造函数,使用指定的底层容器
|
|
| ~queue ()=default |
| | 析构函数
|
| NEFORCE_NODISCARD size_type | size () const noexcept(noexcept(seq_.size())) |
| | 获取队列大小
|
| NEFORCE_NODISCARD bool | empty () const noexcept(noexcept(seq_.empty())) |
| | 检查队列是否为空
|
| NEFORCE_NODISCARD reference | front () noexcept(noexcept(seq_.front())) |
| | 访问队首元素
|
| NEFORCE_NODISCARD const_reference | front () const noexcept(noexcept(seq_.front())) |
| | 常量版本,访问队首元素
|
| NEFORCE_NODISCARD reference | back () noexcept(noexcept(seq_.back())) |
| | 访问队尾元素
|
| NEFORCE_NODISCARD const_reference | back () const noexcept(noexcept(seq_.back())) |
| | 常量版本,访问队尾元素
|
| NEFORCE_NODISCARD iterator | begin () noexcept(noexcept(seq_.begin())) |
| | 获取起始迭代器
|
| NEFORCE_NODISCARD iterator | end () noexcept(noexcept(seq_.end())) |
| | 获取结束迭代器
|
| NEFORCE_NODISCARD const_iterator | begin () const noexcept(noexcept(seq_.begin())) |
| | 获取常量起始迭代器
|
| NEFORCE_NODISCARD const_iterator | end () const noexcept(noexcept(seq_.end())) |
| | 获取常量结束迭代器
|
| NEFORCE_NODISCARD const_iterator | cbegin () const noexcept(noexcept(seq_.cbegin())) |
| | 获取常量起始迭代器
|
| NEFORCE_NODISCARD const_iterator | cend () const noexcept(noexcept(seq_.cend())) |
| | 获取常量结束迭代器
|
| void | push (const T &value) |
| | 入队操作(拷贝版本)
|
| void | push (T &&value) |
| | 入队操作(移动版本)
|
| void | pop () noexcept(noexcept(seq_.pop_front())) |
| | 出队操作
|
| template<typename... Args> |
| decltype(auto) | emplace (Args &&... args) |
| | 在队尾就地构造元素
|
| void | swap (queue &other) noexcept(is_nothrow_swappable_v< Sequence >) |
| | 交换两个队列的内容
|
| NEFORCE_NODISCARD bool | operator== (const queue &rhs) const noexcept(noexcept(seq_==rhs.seq_)) |
| | 相等比较操作符
|
| NEFORCE_NODISCARD bool | operator< (const queue &rhs) const noexcept(noexcept(seq_< rhs.seq_)) |
| | 小于比较操作符
|
| NEFORCE_NODISCARD constexpr decltype(auto) | size () const noexcept(noexcept(derived().size())) |
| | 获取集合大小
|
| NEFORCE_NODISCARD constexpr bool | empty () const noexcept(noexcept(derived().empty())) |
| | 检查集合是否为空
|
| NEFORCE_NODISCARD constexpr bool | operator== (const T &rhs) const noexcept(noexcept(derived()==rhs)) |
| | 相等比较运算符
|
| NEFORCE_NODISCARD constexpr bool | operator!= (const T &rhs) const noexcept(noexcept(!(*this==rhs))) |
| | 不等比较运算符
|
| NEFORCE_NODISCARD constexpr bool | operator< (const T &rhs) const noexcept(noexcept(derived()< rhs)) |
| | 小于比较运算符
|
| NEFORCE_NODISCARD constexpr bool | operator> (const T &rhs) const noexcept(noexcept(rhs< derived())) |
| | 大于比较运算符
|
| NEFORCE_NODISCARD constexpr bool | operator<= (const T &rhs) const noexcept(noexcept(!(derived() > rhs))) |
| | 小于等于比较运算符
|
| NEFORCE_NODISCARD constexpr bool | operator>= (const T &rhs) const noexcept(noexcept(!(derived()< rhs))) |
| | 大于等于比较运算符
|
template<typename T, typename Sequence = deque<T>>
class queue< T, Sequence >
队列容器适配器
- 模板参数
-
| T | 元素类型 |
| Sequence | 底层容器类型,默认为deque<T> |
队列是一种容器适配器,提供先进先出的数据结构特性。 元素只能在队尾插入,在队首删除。支持基本的队列操作: 入队(push)、出队(pop)、访问队首(front)和队尾(back)元素。
默认使用deque作为底层容器,也可指定其他支持front、back、 push_back和pop_front操作的容器(如list)。
在文件 queue.hpp 第 36 行定义.