O'Reilly logo

Mastering C++ Programming by Jeganathan Swaminathan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Commonly used APIs in a map

The following table shows the commonly used map APIs:

API

Description

at ( key )

This returns the value for the corresponding key if the key is found; otherwise it throws the std::out_of_range exception

operator[ key ]

This updates an existing value for the corresponding key if the key is found; otherwise it will add a new entry with the respective key=>value supplied

empty()

This returns true if the map is empty, and false otherwise

size()

This returns the count of the key=>value pairs stored in the map

clear()

This clears the entries stored in the map

count()

This returns the number of elements matching the given key

find()

This finds the element with the specified ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required