We are committed to provide service 24 X 7

Deals, Shopping, Training, Tools

Tag: map()

C++ : Map Tutorial -Part 2: Map and External Sorting Criteria / Comparator

In this article we will discuss how to use external sorting criteria for keys in std::map and points that we need to take care with external sorting criteria. Default sorting criteria for keys in std::map is operator “<” i.e. std::less<T>. So, while creating std::map if we don’t specify the external sorting criteria then default criteria …

C++ : Map Tutorial -Part 2: Map and External Sorting Criteria / ComparatorRead More

C++ : Map Tutorial Part 3: Using User defined class objects as keys in std::map

In this article we will discuss how to use User defined classes as key in std::map. By default std::map uses “operator <” as sorting criteria for keys. For default data types like int and std::string etc, operator < is available by default but for User defined classes operator < is not available by default. Advertisements …

C++ : Map Tutorial Part 3: Using User defined class objects as keys in std::mapRead More

Set vs Map : How to choose a right associative container ?

In this article we will discuss how set and map are different and what factors we need to keep in mind while choosing right associative container. Let’s start from set, Set : Advertisements Set is an associative container which we need to store unique elements. It always keeps the elements in sorted order. Internally it …

Set vs Map : How to choose a right associative container ?Read More

C++ Map Insert Example

In this article we will discuss how to insert a key value pair in std::map. Map internally store elements in a pair of key value i.e. Advertisements std::pair<key Type, Value Type> So, to add an element in map we can use one of its member function insert() i.e. pair<iterator,bool> insert (const value_type& element); It accepts …

C++ Map Insert ExampleRead More

How to iterate a map in reverse order – C++

In this article we will discuss how to iterate a map in reverse order. Map store the elements in sorted order of keys. For example, if you store following elements in map i.e. Advertisements {“aaa”, 10}, {“ddd”, 11}, {“bbb”, 12}, {“ccc”, 13} It will internally store the elements in sorted order of keys i.e. {“aaa”, …

How to iterate a map in reverse order – C++Read More

C++ : How to Initialize a map in one line using initialzer_list ?

In this article we will discuss how to initialize a map with std::initialzer_list<T>. Let’s create a map of string as key and int as value and initialize it with initializer_list i.e. Advertisements // Initialize a Map of string & int using initializer_list std::map<std::string, int> mapOfMarks = { {“Riti”,2}, {“Jack”,4} }; Here compiler will create following …

C++ : How to Initialize a map in one line using initialzer_list ?Read More

Cart

Your Cart is Empty

Back To Shop