Queues
- properties of queue:
- list of elements with access only at both ends
(front, back).
- insert at the end, delete from front.
- first in first out (FIFO),
first come first served (FCFS)
- Implementation:
- Use any container that supports the operations:
-
size()
-
empty()
-
push_back()
-
front()
-
pop_front()
- Constructor & Operations:
- queue();
- bool empty()
const;
- T& front();
const T& front();
Return reference to the value of the front
of queue.
- void pop();
Remove the item from the
front of queue.
- void push(const
T& item);
Insert the argument item at the
back of the queue.
- int size()
const;
- Priority Queues
- Similar to queue, the operation 'insert' is same as
queue.
However, delete the most
important (highest priority)element from the list.
T& top();
Return a reference to the element having the
highest priority.