The unordered_map::count() is a builtin method in C++ which is used to count the number of elements present in an unordered_map with a given key.
Note: As unordered_map does not allow to store elements with duplicate keys, so the count() function basically checks if there exists an element in the unordered_map with a given key or not.
Parameters: This function accepts a single parameter key which is needed to be checked in the given unordered_map container.
Return Value: This function returns 1 if there exists a value in the map with the given key, otherwise it returns 0.
Below programs illustrate the unordered_map::count() function:
Count of elements in map, mapped with key 3: 1
- std::count() in C++ STL
- multimap::count() in C++ STL
- set count() function in C++ STL
- map count() function in C++ STL
- bitset count() in C++ STL
- CSS | column-count Property
- multiset count() function in C++ STL
- unordered_multimap count() function in C++ STL
- unordered_multiset count() function in C++ STL
- Count numbers having 0 as a digit
- unordered_set count() function in C++ STL
- Count the number of 1's and 0's in a binary array using STL in C++ ?
- Count the pairs of vowels in the given string
- Count number of unique Triangles using STL | Set 1 (Using set)
- C++ Program to count Vowels in a string using Pointer
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.