c++ count and find function

count

Count the number of occurrences of a character;
the method of use is count(begin, end, 'a'), where begin refers to the start address, end refers to the end address, and the third parameter refers to the character to be searched.
In unordered_set: the count function will only return 1 or 0. Because there are no repeating elements.
Usage: This function accepts a single parameter element. Indicates whether the element to be checked exists in the container. This function returns 1 if the element exists in the container, else it returns 0.

unordered_set_name.count(element)  

In the map, it is to find the number with a certain key. Since there are no repeated keys, the return is either 0 or 1;

find

Use find to return the position of the searched element, if not, return map.end()
Usage method: find (a.begin(), a.end(), value)
If found within the search range, return is The address of value, if not found, return the address a+length or the
find() function in a.end() string to find the target string that appears for the first time. Returns s.npos(end position) if not found.

Guess you like

Origin blog.csdn.net/PETERPARKERRR/article/details/124036883