The set::count() is a built-in function in C++ STL which returns the number of times an element occurs in the set. It can only return 1 or 0 as the set container contains unique elements only.
Parameters: The function accepts one mandatory parameter element which specifies the element whose count is to be returned.
Return Value: The function returns 1 or 0 as the set contains unique elements only. It returns 1 if the value is present in the set container. It returns 0 if it is not present in the container.
Below is the illustration of the above function.
11 is present in the set 18 is not present in the set
- map count() function in C++ STL
- unordered_set count() function in C++ STL
- unordered_multiset count() function in C++ STL
- unordered_multimap count() function in C++ STL
- multiset count() function in C++ STL
- Count the number of objects using Static member function
- Function Overloading vs Function Overriding in C++
- What happens when a virtual function is called inside a non-virtual function in C++
- std::count() in C++ STL
- bitset count() in C++ STL
- multimap::count() in C++ STL
- unordered_map count() in C++
- Count numbers having 0 as a digit
- Count smaller elements on right side using Set in C++ STL
- Count number of unique Triangles using STL | Set 1 (Using set)
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.