Map, types of map constructors and operators in C++

A map is a list of key and value pairs. If a key is provided then the particular value can be found out. A key has to be unique in a map.

A map class can be declared as:

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

Types of map constructors:

Type-1: Empty map

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

Type-2: Map having same elements as obj

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

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

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

Types of map operators: [ ], ==, <, <=, !=, >, >=

Leave a Reply