The map::count() is a built-in function in C++ STL which returns 1 if the element with key K is present in the map container. It returns 0 if the element with key K is not present in the container.
Parameters: The function accepts a mandatory parameter k which specifies the key to be searched in the map container.
Return Value: The function returns the number of times the key K is present in the map container. It returns 1 if the key is present in the container as the map only contains a unique key. It returns 0 if the key is not present in the map container.
Below program illustrates the above function:
The key 1 is present The key 100 is not present
- set count() function in C++ STL
- unordered_multimap count() function in C++ STL
- unordered_multiset count() function in C++ STL
- unordered_set count() function in C++ STL
- multiset count() function in C++ STL
- Count the number of objects using Static member function
- How to call some function before main() function in C++?
- Function Overloading vs Function Overriding in C++
- std::count() in C++ STL
- unordered_map count() in C++
- Count of quadruplets with given Sum | Set 2
- 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
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.