Translations of this page?:

empty

Syntax:

    #include <queue>
    bool empty() const;

The empty() function returns true if the queue has no elements, false otherwise.

For example, the following code uses empty() as the stopping condition on a while loop to clear a queue while displaying its contents:

   queue<int> q;
   for( int i = 0; i < 5; i++ ) {
     q.push(i);
   }
   while( !q.empty() ) {
     cout << q.front() << endl;
     q.pop();
   }

Related Topics: size

 
• • • IndexRecent changesRSScc