Visual C++ - Implementing Queue
Queue elements are following FIFO structure. Note that queue elements will be pushed at the end and poped from the begining of the queue so that the first elements gets in will come out first.
But priority queue will check for the priority and then place the element in the right place based on priority.
In another words, if you have a priority_queue of integers, then if you iterate through all elements, then it will be in sorted order by Descending.
#include < iostream > #include < deque > #include < queue > #include < stack > #include < map > #include < string > void main() { std::cout << "Queue Collection: \n"; std::queue< std::string > myCollection; myCollection.push("David"); myCollection.push("Erin"); myCollection.push("John"); while(myCollection.size()) { std::string type = myCollection.front(); std::cout << "\n" << type.c_str(); myCollection.pop(); } std::cout << "\n\n"; return; }
Sample Output
Queue Collection:
David
Erin
John
|