.empty()

The .empty() method returns true if the size of the queue is 0. Otherwise, it returns false.

Syntax

The .empty() method can be called on a queue using the following syntax:

queueName.empty();

Codebyte Example

The following codebyte example checks whether the temperatures queue is empty and prints "The queue is empty." if it is. Else, it prints "The queue is not empty.".

Edit this page on GitHub

Contributors

Interested in helping build Docs? Read the Contribution Guide or share your feedback form.

Learn C++ on Codecademy