Logo

Programming-Idioms

History of Idiom 51 > diff from v43 to v44

Edit summary for version 44 by Stanley:
New Cpp implementation by user [Stanley]

Version 43

2019-09-26, 18:47:23

Version 44

2019-09-30, 06:30:40

Idiom #51 Check if map contains key

Determine whether map m contains an entry for key k

Illustration

Idiom #51 Check if map contains key

Determine whether map m contains an entry for key k

Illustration
Extra Keywords
table dictionary hash
Extra Keywords
table dictionary hash
Imports
#include <map>
Code
bool key_exists = m.count(k) != 0;
Comments bubble
Need C++14
Doc URL
https://en.cppreference.com/w/cpp/container/map/count