queue::empty()
empty() function is used to check if the queue container is empty or not.
Syntax
queueName.empty()
Parameters
- This function does not accept any parameter.
Return Value
- It returns True if the list is empty, else it returns False.
Examples
Input: myqueue = 1, 2, 3 myqueue.empty(); Output: False Input: myqueue myqueue.empty(); Output: True
Errors and Exceptions
- Shows an error if a parameter is passed.
- Shows no exception throw guarantee.
queue::empty() and queue::size() in C++ STL
Queue is a type of container adaptor that operate in a first in first out (FIFO) type of arrangement. Elements are inserted at the back (end) and are deleted from the front.