Queue : STL in C++

Finally, i get to post something about the queue implementation in stl( standard template library ). The queue is a data structure that defines the so-called push and pop operation, which literally means adding new element at the end of a list, and extracting an element from the front of the list respectively. Thus, if the following numbers are pushed into the queue in order ( 1, 2, 3), the first one to be popped out is 1, then 2 and finally, 3. I hope you get the point.

Here goes an implementation using stl.

#include 
#include
using namespace std;

int main()
{
queue Q;
Q.push( 1 );
Q.push( 2 );
Q.push( 3 );
cout <<>

As you can probably guess, the output is,

1 2 3



Posted bysamir at 1:36 AM  

0 comments:

Post a Comment