Queue of c++STL container

Introduction to
Queuequeue is a queue container, a "first in, first out" container.
queue simply decorates the deque container and becomes another kind of container.
#include
The default structure of the queue object is
implemented using template classes. The default structure of the queue object is: queue queT; such as:
queue queInt; //A queue container for storing int.
queue queFloat; //A queue container that stores floats.
queue queString; //A queue container for storing strings.

//A pointer type or a custom type can also be set in the angle brackets.

The push() and pop() methods of queue queue.push(
elem); //Add elements to the end of the
queue queue.pop(); //Remove the first element from the head of the queue

queue queInt;
queInt.push(1); queInt.push(3);
queInt.push(5); queInt.push(7);
queInt.push(9); queInt.pop();
queInt.pop();
At this time, the elements stored in queInt are the
copy construction and assignment of queue objects of 5, 7, and 9 queue
(const queue &que); //copy constructor
queue& operator=(const queue &que); //overload equal sign operator
queue queIntA ;
queIntA.push(1);
queIntA.push(3);
queIntA.push(5);
queIntA.push(7);
queIntA.push(9);
queue queIntB(queIntA); //copy structure
queue queIntC;
queIntC = queIntA; //
Data access of
assigned queuequeue.back(); //Returns the last element
queue.front(); //Returns the first element
queue queIntA;
queIntA.push(1);
queIntA. push(3);
queIntA.push(5);
queIntA.push(7);
queIntA.push(9);
int iFront = queIntA.front(); //1
int iBack = queIntA.back(); //9
queIntA.front() = 11; //11
queIntA .back() = 19; //19
queue
sizequeue.empty(); //determine whether the queue is
emptyqueue.size(); //return the size of the
queue queue queIntA;
queIntA.push(1);
queIntA.push(3);
queIntA.push(5);
queIntA.push(7);
queIntA.push(9);
if (!queIntA.empty())
{ int iSize = queIntA.size(); //5 }

Guess you like

Origin blog.csdn.net/it_xiangqiang/article/details/109235136
Recommended