empty [C++ Reference]
Keywords: stl,multiset,empty
Date: 2009-09-16T06:34:13-0700

[[empty]]
C++ Reference
Translations of this page?:

- en
- br-pt
- cn
- cz
- de
- es
- fr
- it
- jp
- nl
- pl
- ro
- ru
- sk
- tr
- tw

## empty

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

Edit this page • Old revisions
• • • Login • Index • Recent changes • RSS • cc •