STD::QUEUE(3cxx)

πŸ¦‹ std::queue< _Tp, _Sequence > β€” NAME πŸ’…

okay so bestie, welcome to the 3cxx manual page for std::queue< _Tp, _Sequence > β€” and honestly? It's giving β€œstandard container giving FIFO behavior.” That's the whole NAME vibe: a standard container that does first-in-first-out, no cap. πŸŽ€


✨ SYNOPSIS ✨

#include <queue>

🌸 Public Types 🌸

  • typedef _Sequence::const_reference const_reference
  • typedef _Sequence container_type
  • typedef _Sequence::reference reference
  • typedef _Sequence::size_type size_type
  • typedef _Sequence::value_type value_type

πŸ’… Public Member Functions πŸ’…

  • template<typename _Seq = _Sequence, typename _Requires = typename enable_if<is_default_constructible<_Seq>::value>::type> queue () β€” Default constructor creates no elements.
  • queue (_Sequence &&__c)
  • template<typename _Alloc , typename _Requires = _Uses<_Alloc>> queue (_Sequence &&__c, const _Alloc &__a)
  • template<typename _Alloc , typename _Requires = _Uses<_Alloc>> queue (const _Alloc &__a)
  • queue (const _Sequence &__c)
  • template<typename _Alloc , typename _Requires = _Uses<_Alloc>> queue (const _Sequence &__c, const _Alloc &__a)
  • template<typename _Alloc , typename _Requires = _Uses<_Alloc>> queue (const queue &__q, const _Alloc &__a)
  • template<typename _Alloc , typename _Requires = _Uses<_Alloc>> queue (queue &&__q, const _Alloc &__a)
  • reference back ()
  • const_reference back () const
  • template<typename... _Args> decltype(auto) emplace (_Args &&... __args)
  • bool empty () const
  • reference front ()
  • const_reference front () const
  • void pop () β€” Removes first element.
  • void push (const value_type &__x) β€” Add data to the end of the queue.
  • void push (value_type &&__x)
  • size_type size () const
  • void swap (queue &__q) noexcept(__is_nothrow_swappable< _Sequence >::value)

🧚 Protected Attributes 🧚

  • _Sequence c β€” c is the underlying container.

πŸ¦‹ Friends πŸ¦‹

  • template<typename _Tp1 , typename _Seq1 > bool operator< (const queue< _Tp1, _Seq1 > &, const queue< _Tp1, _Seq1 > &)
  • template<typename _Tp1 , three_way_comparable _Seq1> compare_three_way_result_t< _Seq1 > operator<=> (const queue< _Tp1, _Seq1 > &, const queue< _Tp1, _Seq1 > &)
  • template<typename _Tp1 , typename _Seq1 > bool operator== (const queue< _Tp1, _Seq1 > &, const queue< _Tp1, _Seq1 > &)

πŸ’– Detailed Description πŸ’–

template<typename _Tp, typename _Sequence = deque<_Tp>>
    class std::queue< _Tp, _Sequence >"A standard container giving FIFO
    behavior.

🌈 Template Parameters 🌈

  • _Tp β€” Type of element.
  • _Sequence β€” Type of underlying sequence, defaults to deque<_Tp>.

Okay so here's the tea: this thing meets many of the requirements of a container, but it does not define anything to do with iterators. Very few of the other standard container interfaces are defined. It's lowkey not a β€œtrue container” at all β€” it's an adaptor. It holds another container and gives you a wrapper interface to that container. The wrapper is literally what enforces strict first-in-first-out queue behavior. ✨

The second template parameter defines the type of the underlying sequence/container. It defaults to std::deque, but it can be any type that supports front, back, push_back, and pop_front, such as std::list or an appropriate user-defined type. Iconic flexibility, honestly.

Members not found in normal containers are container_type β€” which is a typedef for the second Sequence parameter β€” and push and pop, which are standard queue/FIFO operations. Periodt. 🫢


🌈 Constructor & Destructor Documentation 🌈

πŸŽ€ queue () β€” default constructor

template<typename _Tp , typename _Sequence  = deque<_Tp>> template<typename
    _Seq  = _Sequence, typename _Requires  = typename
    enable_if<is_default_constructible<_Seq>::value>::type> std::queue< _Tp,
    _Sequence >::queue () [inline]

Default constructor creates no elements. Empty queue, clean slate, main character energy. πŸ’…


πŸ”₯ Member Function Documentation πŸ”₯

back()

template<typename _Tp , typename _Sequence  = deque<_Tp>> reference
    std::queue< _Tp, _Sequence >::back () [inline]

Returns a read/write reference to the data at the last element of the queue.

References std::queue< _Tp, _Sequence >::c.

back() const

template<typename _Tp , typename _Sequence  = deque<_Tp>> const_reference
    std::queue< _Tp, _Sequence >::back () const [inline]

Returns a read-only (constant) reference to the data at the last element of the queue.

References std::queue< _Tp, _Sequence >::c.

empty() const

template<typename _Tp , typename _Sequence  = deque<_Tp>> bool std::queue<
    _Tp, _Sequence >::empty () const [inline]

Returns true if the queue is empty.

References std::queue< _Tp, _Sequence >::c.

front()

template<typename _Tp , typename _Sequence  = deque<_Tp>> reference
    std::queue< _Tp, _Sequence >::front () [inline]

Returns a read/write reference to the data at the first element of the queue.

References std::queue< _Tp, _Sequence >::c.

front() const

template<typename _Tp , typename _Sequence  = deque<_Tp>> const_reference
    std::queue< _Tp, _Sequence >::front () const [inline]

Returns a read-only (constant) reference to the data at the first element of the queue.

References std::queue< _Tp, _Sequence >::c.

pop()

template<typename _Tp , typename _Sequence  = deque<_Tp>> void std::queue<
    _Tp, _Sequence >::pop () [inline]

Removes first element. This is a typical queue operation. It shrinks the queue by one. The time complexity of the operation depends on the underlying sequence.

⚠️ bestie, note that no data is returned, and if the first element's data is needed, it should be retrieved before pop() is called. Like, grab your snack before you yeet it. 😭

References std::queue< _Tp, _Sequence >::c.

push (const value_type &__x)

template<typename _Tp , typename _Sequence  = deque<_Tp>> void std::queue<
    _Tp, _Sequence >::push (const value_type & __x) [inline]

Add data to the end of the queue.

Parameters

  • __x β€” Data to be added.

This is a typical queue operation. The function creates an element at the end of the queue and assigns the given data to it. The time complexity of the operation depends on the underlying sequence.

References std::queue< _Tp, _Sequence >::c.

size() const

template<typename _Tp , typename _Sequence  = deque<_Tp>> size_type
    std::queue< _Tp, _Sequence >::size () const [inline]

Returns the number of elements in the queue.

References std::queue< _Tp, _Sequence >::c.


πŸ“ Member Data Documentation πŸ“

template<typename _Tp , typename _Sequence  = deque<_Tp>> _Sequence
    std::queue< _Tp, _Sequence >::c [protected]

c is the underlying container. The whole queue is lowkey built on this one protected member, and it's referenced by std::queue< _Tp, _Sequence >::back(), std::queue< _Tp, _Sequence >::back(), std::queue< _Tp, _Sequence >::empty(), std::queue< _Tp, _Sequence >::front(), std::queue< _Tp, _Sequence >::front(), std::operator<(), std::operator==(), std::queue< _Tp, _Sequence >::pop(), std::queue< _Tp, _Sequence >::push(), and std::queue< _Tp, _Sequence >::size(). Yes, back and front show up twice in that list β€” that's literally the list, I'm not editing it. πŸ’€


πŸ‘‘ Author πŸ‘‘

Generated automatically by Doxygen for libstdc++ from the source code. That's the author line, bestie β€” Doxygen did the typing, libstdc++ brought the lore. 🫢


That's the whole page, bestie. Source/version: libstdc++. Manual section: 3cxx. Date: the page doesn't print one, so I'm not gonna manifest a fake date β€” periodt. πŸ’–

πŸ“¦ where this page comes from