cppreference.com -> C++ Maps -> Details

C++ Maps

C++ Maps can be used to store key/value pairs.


begin

Syntax:

  iterator begin();

The function begin() returns an iterator to the first element in the map.


clear

Syntax:

  void clear();

The clear() function deletes all elements from the map.


count

Syntax:

  size_type count( const KEY_TYPE &key );

The function count() returns the number of occurrences of key in the map.


empty

Syntax:

  bool empty();

The function empty() returns true if the map is empty, and false otherwise.


end

Syntax:

  iterator end();

The end() function returns an iterator to the end of the map.


equal_range

Syntax:

  pair equal_range( const KEY_TYPE &key );

The function equal_range() returns two iterators - one to the first element that contains key, another to the last element that contains key.


erase

Syntax:

  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.


find

Syntax:

  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.


get_allocator

Syntax:

  allocator_type get_allocator();

The get_allocator() function returns the allocator of the map.


insert

Syntax:

  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_comp

Syntax:

  key_compare key_comp();

The function key_comp() returns the function that compares keys.


lower_bound

Syntax:

  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.


max_size

Syntax:

  size_type max_size();

The function max_size() returns the maximum number of elements that the map can hold.


rbegin

Syntax:

  reverse_iterator rbegin();

The rbegin() function returns a reverse iterator to the end of the map.


rend

Syntax:

  reverse_iterator rend();

The function rend() returns a reverse iterator to the start of the map.


size

Syntax:

  size_type size();

The function size() returns the number of elements currently in the map.


swap

Syntax:

  void swap( map &obj );

The swap() function exchanges the elements in obj with those in the current map.


upper_bound

Syntax:

  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_comp

Syntax:

  value_compare value_comp();

The value_comp() function returns the function that compares values.