Student Of Fortune

Queue Sample In C++ Language

Share on :
Queue is a data structure with the concept of FIFO (First In First Out), the same as with the Stack in a queue can be done with arrays and linked list (as far as I know). Array or linked list in a queue depends on the problem to be solved with a queue data structure. In the queue there are 2 basic operations namely deQueue to remove data and Enqueue to enter data in the queue.

see the following code :
// constructing queues
#include <iostream>
#include <deque>
#include <list>
#include <queue>
using namespace std;

int main ()
{
deque<int> mydeck (3,100); // deque with 3 elements
list<int> mylist (2,200); // list with 2 elements

queue<int> first; // empty queue
queue<int> second (mydeck); // queue initialized to copy of deque

queue<int,list<int> > third; // empty queue with list as underlying container
queue<int,list<int> > fourth (mylist);

cout << "size of first: " << (int) first.size() << endl;
cout << "size of second: " << (int) second.size() << endl;
cout << "size of third: " << (int) third.size() << endl;
cout << "size of fourth: " << (int) fourth.size() << endl;

return 0;
}

0 comments on Queue Sample In C++ Language :

Post a Comment and Don't Spam!

Dont Spam please

 
Recommended Post Slide Out For Blogger

Recent Comments

My Rank