Syntax:
#include <set> bool empty() const;
The empty() function returns true if the multiset has no elements, false otherwise.
For example, the following code uses empty() as the stopping condition on a while loop to clear a multiset and display its contents in reverse order:
multiset<int> ms; for( int i = 0; i < 5; i++ ) { ms.insert(i); } while( !ms.empty() ) { multiset<int>::iterator iter = ms.end(); iter--; cout << *iter << endl; ms.erase( iter ); }
Related Topics: size