set::empty
如果集合为空,测试。
bool empty( ) const;
返回值
true,如果集合为空; false,如果设置的非空。
示例
// set_empty.cpp
// compile with: /EHsc
#include <set>
#include <iostream>
int main( )
{
using namespace std;
set <int> s1, s2;
s1.insert ( 1 );
if ( s1.empty( ) )
cout << "The set s1 is empty." << endl;
else
cout << "The set s1 is not empty." << endl;
if ( s2.empty( ) )
cout << "The set s2 is empty." << endl;
else
cout << "The set s2 is not empty." << endl;
}
要求
标头: <set>
命名空间: std