size
Syntax:
#include <set> size_type size() const;
The size() function returns the number of elements in the current set.
For example, the following code uses size() to determine the number of elements in a 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 size of the set cout << charSet.size(); // output is "8" (the characters in the set are " HTehlor")
Related Topics: empty