queue::queue
Konstrukcje kolejki, która jest pusta lub który jest kopię obiektu kontenera podstawowego.
queue( );
explicit queue(
const container_type& _Right
);
Parametry
- _Right
Const kontenera kolejki konstruowanej ma być kopią.
Uwagi
Domyślny kontener podstawowy dla kolejki jest deque.Można również określić listę jako kontener podstawowy, ale nie można określić wektor, ponieważ brakuje wymaganego pop_front funkcji składowej.
Przykład
// queue_queue.cpp
// compile with: /EHsc
#include <queue>
#include <vector>
#include <list>
#include <iostream>
int main( )
{
using namespace std;
// Declares queue with default deque base container
queue <char> q1;
// Explicitly declares a queue with deque base container
queue <char, deque<char> > q2;
// These lines don't cause an error, even though they
// declares a queue with a vector base container
queue <int, vector<int> > q3;
q3.push( 10 );
// but the following would cause an error because vector has
// no pop_front member function
// q3.pop( );
// Declares a queue with list base container
queue <int, list<int> > q4;
// The second member function copies elements from a container
list<int> li1;
li1.push_back( 1 );
li1.push_back( 2 );
queue <int, list<int> > q5( li1 );
cout << "The element at the front of queue q5 is "
<< q5.front( ) << "." << endl;
cout << "The element at the back of queue q5 is "
<< q5.back( ) << "." << endl;
}
Wymagania
Nagłówek:<kolejki>
Przestrzeń nazw: std