Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

c++ unordered_map check if key exists

bool checkKey (int key, const std::unordered_map<int, int> &m) {
  if (m.find(key) == m.end()) {
    return false; //Key is not in the map
  }
  
  return true; //Key is in the map
}
 
PREVIOUS NEXT
Tagged: #check #key #exists
ADD COMMENT
Topic
Name
4+9 =