Namespaces
Variants
Views
Actions

Difference between revisions of "cpp/container/queue"

From cppreference.com
< cpp‎ | container
(Undo revision 47165 by Eendy (talk) too categorical, and a copy-paste error)
Line 11: Line 11:
  
 
The class template acts as a wrapper to the underlying container - only a specific set of functions is provided. The queue pushes the elements on the back of the underlying container and pops them from the front.
 
The class template acts as a wrapper to the underlying container - only a specific set of functions is provided. The queue pushes the elements on the back of the underlying container and pops them from the front.
 
The only reason to use the {{c|std::stack}} instead of the underlying container is to make it clear that only stack operations are performed.
 
  
 
===Template parameters===
 
===Template parameters===

Revision as of 10:32, 26 April 2013

 
 
 
 
Defined in header <queue>
template<

    class T,
    class Container = std::deque<T>

> class queue;

The std::queue class is a container adapter that gives the programmer the functionality of a queue - specifically, a FIFO (first-in, first-out) data structure.

The class template acts as a wrapper to the underlying container - only a specific set of functions is provided. The queue pushes the elements on the back of the underlying container and pops them from the front.

Contents

Template parameters

T - The type of the stored elements.
Container - The type of the underlying container to use to store the elements. The container must satisfy the requirements of Template:concept. Additionally, it must provide the following functions with the usual semantics:
  • back()
  • front()
  • push_back()
  • pop_front()

The standard containers std::vector, std::deque and std::list satisfy these requirements.

Member types

Template:cpp/container/dcl list container typeTemplate:cpp/container/dcl list value typeTemplate:cpp/container/dcl list size typeTemplate:cpp/container/dcl list referenceTemplate:cpp/container/dcl list const reference
Member type Definition

Member functions

Template:cpp/container/dcl list constructorTemplate:cpp/container/dcl list destructorTemplate:cpp/container/dcl list operator=Template:cpp/container/dcl list frontTemplate:cpp/container/dcl list backTemplate:cpp/container/dcl list emptyTemplate:cpp/container/dcl list sizeTemplate:cpp/container/dcl list pushTemplate:cpp/container/dcl list emplaceTemplate:cpp/container/dcl list popTemplate:cpp/container/dcl list swapTemplate:cpp/container/dcl list c
Element access
Capacity
Modifiers

Member objects

Non-member functions

Template:cpp/container/dcl list operator cmpTemplate:cpp/container/dcl list swap2

Helper classes

Template:cpp/container/dcl list uses allocator