You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Count elements with a specific key
Searches the container for elements with a value of k and returns the number of elements found. Because unordered_set containers do not allow for duplicate values, this means that the function actually returns 1 if an element with that value exists in the container, and zero otherwise.
haystack.find(needle) != haystack.end() -> haystack.count(needle)
With longer variable names, this adds up.
More intuitive: 1 if found, 0 if not; more in line with Python's needle in haystack.
There's no reason this should perform any slower, right?
Activity