multimap STL container class in C++: Types of constructors, operators of multi map

A multimap is a list of key and value pairs. A key can be non unique in a multimap.

A multimap class can be declared as:

template <class Key, class T, class Comp = less<Key>, class Allocator = allocator<T>> class multimap

Types of multimap constructors:

Type-1: Empty multimap

explicit multimap(const Comp &cmpfn = Comp( ), const Allocator &a = Allocator( ) );

Type-2: multimap having same elements as obj

multimap(const multimap<Key, T, Comp, Allocator> &obj);

Type-3: multimap having elements in the range i and j

template <class InIter> multimap(InIter i, InIter j, const Comp &cmpfn = Comp( ), const Allocator &a = Allocator( ));

Types of multimap operators: ==, <, <=, !=, >, >=

Leave a Reply