Share via


hash_set::clear

Note

This API is obsolete. The alternative is unordered_set Class.

Erases all the elements of a hash_set.

void clear( );

Remarks

In Visual C++ .NET 2003, members of the <hash_map> and <hash_set> header files are no longer in the std namespace, but rather have been moved into the stdext namespace. See The stdext Namespace for more information.

Example

// hash_set_clear.cpp
// compile with: /EHsc
#include <hash_set>
#include <iostream>

int main( )
{
   using namespace std;
   using namespace stdext;
   hash_set <int> hs1;
   
   hs1.insert( 1 );
   hs1.insert( 2 );

   cout << "The size of the hash_set is initially " << hs1.size( )
        << "." << endl;

   hs1.clear( );
   cout << "The size of the hash_set after clearing is " 
        << hs1.size( ) << "." << endl;
}
The size of the hash_set is initially 2.
The size of the hash_set after clearing is 0.

Requirements

Header: <hash_set>

Namespace: stdext

See Also

Reference

hash_set Class

Standard Template Library