 Welcome back, in the previous segment we discussed sorting. In this segment I am going to talk about maps and unordered maps. So these are also template classes and we will see details. So let me describe them starting with vectors. So a vector or an array gives us an element when we supply an index. The index must be an integer and it must come from a small range. But sometimes we may want to use indices which are not integers but maybe strings. So for example, given the name of a country, we might want to use the name of a country as an index and we would like back its population or maybe we want back its capital. Now this is exactly what maps or unordered maps can do. And these can be obtained by using header files, map and unordered map. Unordered maps are faster but have some fewer features. So we are going, we will talk about one feature that they have less but they have some other features also. But if you do not need those features, you should really use unordered maps because they are faster. And the reason for these names will become clear soon. Well the reason for the name map should be clear because the map is really in this example mapping the name of a country to the population or it is mapping the name of the country to a capital. So it is like a mathematical map. A mathematical map maps elements of one set to elements of another set. So that is what this is doing. Unordered map will become clear a little bit later. So let us talk about maps. So what is the general form and take some examples. So if I want to define a map, here is what I write. I write the keyword map, then I write in braces the two template arguments, the index type and the value type and then I give the map name. So as an example I can write map string double population. This is going to be useful for doing the thing that we just said given a country let us get its population. So here the indices will have type string. So for example I can have country names and elements will have type double. So that could be population if I want. If it is going to be a map there is a technical requirement that this index type must satisfy. So I might as well mention it later that the index type must be comparable using the less than operator and how that actually comes in we will discuss later. But how do we use this, how do we use a map? So we have a map from strings to doubles and we are our map is called population. So here is what I can do, I can say population index India is 1.37. So this actually creates an entry in the map, it looks like an array access statement but it is a lot more interesting, it is creating an entry and then the index does not have to be an integer in a small range but it can be anything, well it can be string as we have specified over here and it is storing 1.37 in that element of population. So map entry or map element has been created now. I can create more and more and I can print out what is stored in the map. So if I write see out population of China this will print out 1.42, I can update the entries as well. So suppose I just realized that oh no, no this was an old entry and the new population is slightly larger then I can put this new population. So 1.37 will go away and it will be replaced by 1.38. Now you would like to know whether our map contains say a certain country. So I would like to check if a certain index is defined. So say we are doing a lookup, a population lookup service. So somebody types the country and now I want to know whether I have the population with me. So for that I am going to write population.count. So count is a member function on population on those specific maps, it takes a country as an argument and it says look are there is there an element with this country as the index whatever you typed in. So for example if we had placed populations of India, China and US and suppose you typed in Sri Lanka then this population count would turn out to be 0 otherwise it will be 1. And by the way there is a multi map as well which allows you to put several entries and that is why this can be a general number but with maps it has to be either 0 or 1. So if this entry has been defined then we can say print out the population. And if this entry is not defined we can say the population is not known. So this is a very short population lookup service that you can put up. So as you might expect a lot is going on behind the scenes and it is similar and there is actually a very interesting idea and that idea is discussed in chapter 24. It is a bit of an advanced idea so we are not going to consider it in this chapter. If you wish to say that look I have stored a lot of data in the map and I want to print it out, I want to print out all the countries and their population that I know. So you can do that and that will need the use of iterators which we are going to discuss next. The discussion so far also applies to unordered map. So everything that I have said over here just replace map by unordered map and it will work. So what have we discussed? We said that maps are like arrays but the index need not be an integer in a limited range. A map M and this applies to an unordered map as well can be thought of as a pair. So you are storing these pairs, the index and the value pairs. And the way to add a pair is this. So you say M of index equal to value this adds this pair into the map and you can check if a pair is present by writing M dot count, we saw this and whether checking whether that is greater than 0 or not and you can get the value by writing M of index. Unordered maps have similar functionality and this is the end of this segment. In the next segment I am going to talk about iterators and we will conclude this entire lecture sequence. Thank you.