Syntax:
#include <set> size_type count( const key_type& key ) const;
The function count() returns the number of occurrences of key in the set, which is always 0 or 1. count() should run in logarithmic time.
For example, the following code uses count() to determine if elements are contained in the set:
// Create a set of characters set<char> charSet; const char* s = "Hello There"; for( int i=0; i < strlen(s); i++ ) { charSet.insert( s[i] ); } // Display the set cout << charSet.count('A'); cout << charSet.count('T'); // output is "01" (the characters in the set are " HTehlor")