c++ queue code example

Example 1: stl queue

Functions used here:
   q.size() = Returns the size of queue.
   q.push() = It is used to insert elements to the queue.
   q.pop() = To pop out the value from the queue.
   q.front() = Returns the front element of the array.
   q.back() = Returns the back element of the array.

Example 2: queue c++

//Queue is a data structure designed to operate in FIFO(First in First out) context. 
//In queue elements are inserted from rear end and get removed from front end.
 The functions supported by queue:
 ---------------------------------
 empty()   | Tests whether queue is empty or not.
 size()    | Returns the total number of elements present in the queue.
 push()    | Inserts new element at the end of queue.
 emplace() | Constructs and inserts new element at the end of queue.
 pop()     | Removes front element of the queue.
 swap()    | Exchanges the contents of queue with contents of another queue.
 front()   | Returns a reference to the first element of the queue.
 back()    | Returns a reference to the last element of queue.

Example 3: #include

size of first: 0
size of second: 3
size of third: 0
size of fourth: 2

Tags:

Misc Example