cppreference.com -> C++ Maps -> Details |
C++ Maps can be used to store key/value pairs.
iterator begin(); |
The function begin() returns an iterator to the first element in the map.
void clear(); |
The clear() function deletes all elements from the map.
size_type count( const KEY_TYPE &key ); |
The function count() returns the number of occurrences of key in the map.
bool empty(); |
The function empty() returns true if the map is empty, and false otherwise.
iterator end(); |
The end() function returns an iterator to the end of the map.
pair |
The function equal_range() returns two iterators - one to the first element that contains key, another to the last element that contains key.
void erase( iterator pos ); void erase( iterator start, iterator end ); size_type erase( const KEY_TYPE &key ); |
The erase function() either erases the element at pos, erases the elements between start and end, or erases all elements that have the value of key.
iterator find( const KEY_TYPE &key ); |
The find() function returns an iterator to key, or an iterator to the end of the map if key is not found.
allocator_type get_allocator(); |
The get_allocator() function returns the allocator of the map.
iterator insert( iterator pos, const pair<KEY_TYPE,VALUE_TYPE> &val ); void insert( input_iterator start, input_iterator end ); pair<iterator, bool> insert( const pair<KEY_TYPE,VALUE_TYPE> &val ); |
The function insert() either:
key_compare key_comp(); |
The function key_comp() returns the function that compares keys.
iterator lower_bound( const KEY_TYPE &key ); |
The lower_bound() function returns an iterator to the first element which has a value greater than or equal to key.
size_type max_size(); |
The function max_size() returns the maximum number of elements that the map can hold.
reverse_iterator rbegin(); |
The rbegin() function returns a reverse iterator to the end of the map.
reverse_iterator rend(); |
The function rend() returns a reverse iterator to the start of the map.
size_type size(); |
The function size() returns the number of elements currently in the map.
void swap( map |
The swap() function exchanges the elements in obj with those in the current map.
iterator upper_bound( const KEY_TYPE &key ); |
The function upper_bound() returns an iterator to the first element in the map with a key greater than key.
value_compare value_comp(); |
The value_comp() function returns the function that compares values.