Hacker News new | ask | show | jobs
by 8xde0wcNwpslOw 2938 days ago
>checking if a map or set contain a key requires lots of code

Well, we all have our own standards, but...

  std::set<int> numbers = ...;
  if (numbers.count(5)) {} // we have a 5
1 comments

What's the complexity of that operation?
It is exactly the same operation as `contains()` for set/map. There's only a difference between `count()` and `contains()` for multiset/multimap.