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?
https://www.cplusplus.com/reference/unordered_set/unordered_set/count/
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'sneedle in haystack
.There's no reason this should perform any slower, right?