The unordered_set::count() function is a built-in function in C++ STL which is used to count occurrences of a particular element in an unordered_set container. As the unordered_set container does not allows to store duplicate elements so this function is generally used to check if an element is present in the container or not. The function returns 1 if the element is present in the container otherwise it returns 0.
Parameter: This function accepts a single parameter element. This parameter represents the element which is needed to be checked if it is present in the container or not.
Return Value: This function returns 1 if the element is present in the container otherwise it returns 0.
Below programs illustrate the unordered_set::count() function:
sampleSet contains: 25 5 10 15 20 Element 20 is present in the set
sampleSet contains: Welcome To GeeksforGeeks For Geeks Computer Science Portal GeeksforGeeks is present in the set
- set count() function in C++ STL
- map count() function in C++ STL
- unordered_multimap count() function in C++ STL
- unordered_multiset 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
- unordered_map count() in C++
- bitset count() in C++ STL
- multimap::count() in C++ STL
- Count numbers having 0 as a digit
- Count substrings that contain all vowels | SET 2
- 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 firstname.lastname@example.org. 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.