This page contains two tables. The first lists all member functions common to all four associative containers (map, multimap, set, multiset). The second table lists all member functions that appear in one or more of these four containers, but not in all four.

Member functions present in all associative containers

assignment operator
c1 = c2
Assigns one container to another like container (map to map, set to set, and so on).
comparison operators
c1 == c2
Returns true if c1 and c2 are two like containers which have the same size and contain the same values in the same order, and otherwise return false.
c1 != c2
Returns true if c1 == c2 returns false, and otherwise return false.
c1 < c2
Returns true if c1 and c2 are two like containers and if, in the pairwise comparison of the values from c1 and c2, in the first pair in which the two differ the component from c1 is less than the component from c2, and otherwise return false.
c1 <= c2
Returns true if either c1 < c2 or c1 == c2 is true, and otherwise return false.
c1 > c2
Returns true if c2 < c1 is true, and otherwise return false.
c1 >= c2
Returns true if either c1 > c2 or c1 == c2 is true, and otherwise return false.
testing for empty
empty() const
Returns true if container is empty, and otherwise return false.
getting container size
size() const
Returns number of components currently in container.
max_size() const
Returns maximum number of components a container of the given type can hold.
getting iterator access to container locations
begin()
Returns an iterator (or const_iterator) pointing to the first component of a container.
end()
Returns an iterator (or const_iterator) pointing to one-past-the-last component of a container.
rbegin()
Returns a reverse_iterator (or const_reverse_iterator) pointing to the last component of a container.
rend()
Returns a reverse_iterator (or const_reverse_iterator) pointing to one-before-the-first component of a container.
inserting one or more values
insert(p, val)
Inserts val, using p as a "hint" as to where to start looking for the insertion point, and return an iterator pointing to the element inserted if the insertion succeeded or to the element that was already there if (in the case of a map or a set) the insertion failed because the element was already present.
insert(start, end)
Inserts the elements from the range [start,end), possibly from another kind of container. If the receiving container is a map or a set, elements from the incoming range that are already present in the receiving container will not be inserted.
deleting one or more values
erase(someKey)
Removes all elements with key value someKey and return number of elements removed.
erase(iter)
Removes the element pointed to by iter.
erase(start, end)
Removes all elements in the range [start,end).
clear()
Removes all elements from the container, and reduce the size to zero.
counting/searching operations
count(someKey)
Returns the number of times that someKey occurs (0 or 1 for map or set).
find(someKey)
Returns an iterator to the (first or only) element of the container whose key is someKey, or an iterator to one-past-the-last if someKey not found.
lower_bound(someKey)
Returns a [const] iterator to the (first or only) element of the container whose key is greater than or equal to someKey.
upper_bound(someKey)
Returns a [const] iterator to the (first or only) element of the container whose key is greater than someKey.
equal_range(someKey)
Returns a pair of iterators in which the first iterator points to the lower bound, and the second points to the upper bound, of someKey in the container.
miscellaneous operations
swap(otherLikeContainer)
Exchanges elements in the invoking container with those in otherLikeContainer (map with map, set with set, multimap with multimap, multiset with multiset).
get_allocator()
Returns the allocator of the container.
key_comp()
Returns the function object that compares keys.
value_comp()
Returns the function object that compares values.

Member functions present in some associative containers
but not common to all

map-multimap constructors
ContainerType<keyType, ValueType> c;
Constructs an empty container.
ContainerType<KeyType, ValueType> c(inIterBegin, inIterEnd);
Constructs a container with elements from the range [inIterBegin, inIterEnd).
ContainerType<KeyType, ValueType> c(otherLikeContainer);
Copy constructor.
set-multiset constructors
ContainerType<T> c;
Constructs an empty container.
ContainerType<T> c(inIterBegin, inIterEnd);
Constructs a container with elements from the range [inIterBegin, inIterEnd).
ContainerType<T> c(otherLikeContainer);
Copy constructor.
map-only member function
operator[someKey]
Returns a reference to the value associated with the key specified by someKey. If this key does not already exist in the map, it is inserted. The value corresponding to key someKey in the inserted pair is the default value of value_type for the current container.
map-and-set-only member function
insert(val)
Inserts val into invoking container, if it is not already there. Returns pair<iterator, true> if inserted, and otherwise return pair<iterator, false>, and with the iterator component of pair pointing to the inserted element if insertion succeeded, and to the element that was already there if insertion did not succeed.
multimap-and-multiset-only member function
insert(val)
Inserts val into invoking container and returns an iterator pointing to the inserted element.