Basic std::map Member Functions
Some basic functions associated with std::map are:
- begin() ā Returns an iterator to the first element in the map.
- end() ā Returns an iterator to the theoretical element that follows the last element in the map.
- size() ā Returns the number of elements in the map.
- max_size() ā Returns the maximum number of elements that the map can hold.
- empty() ā Returns whether the map is empty.
- pair insert(keyvalue, mapvalue) ā Adds a new element to the map.
- erase(iterator position) ā Removes the element at the position pointed by the iterator.
- erase(const g)ā Removes the key-value āgā from the map.
- clear() ā Removes all the elements from the map.
Map in C++ Standard Template Library (STL)
Maps are associative containers that store elements in a mapped fashion. Each element has a key value and a mapped value. No two mapped values can have the same key values.
std::map is the class template for map containers and it is defined inside the <map> header file.