T
- Type of elements.
Return: none
Arguments: T
Pushes element with a given value to the front.
Return: none
Arguments: none
Removes element from the back.
Return: T
Arguments: none
Gets value of the front element.
Return: T
Arguments: none
Gets value of the back element.
Return: unsigned int
Arguments: none
Gets size of the queue.
Return: bool
Arguments: none
Returns whether the queue is empty.
Library include
#include "path/to/Basic-Data-Structures/include/queue"
Queue declaration
Queue<int> q;
Basic push
, pop
, front
and back
usage
q.push(2); // queue: 2
q.push(4); // queue: 4 2
q.push(3); // queue: 3 4 2
std::cout << q.front() << " " << q.back() << "\n"; // prints: 3 2
q.push(1); // queue: 1 3 4 2
q.pop(); // queue: 1 3 4
std::cout << q.front() << " " << q.back() << "\n"; // prints: 1 4