In this lecture, you will learn about C++ maps, another container type. Maps store key value pairs where we look up a value using the key. You can think of this as being like a dictionary, where if we want to find the definition or definitions of a word, we use the word as the key to look it up in a dictionary and then the value for that key is the definition or definitions for the word. Maps can be much more efficient than the other container types like vectors, when we want to look things up. If we're looking for a value in a vector, we may have to traverse the entire contents of the vector to find the value we're looking for or to discover that it's not there. Maps, on the other hand, can simply use the key to look for that value or to discover that the key is not in the map without traversing the entire container. In this lecture, we're going to use an unordered map, so we don't care about any natural ordering that the keys for the map may or may not have. I'm going to create a map of high scores with the key being a gamer tag, so a string and the value of being an integer. The high score for whatever gamer tag that entry is for. Here's how we declare our variable. We say it's a standard unordered map, and we provide the datatype for the key and the datatype for values. I've given it the variable name high scores and I'm initializing it to an empty map. One way we can add a key value pair to our unordered map is to use the insert function. When we use the insert function, we need to pass in a key value pair. One way we can do that is to call the standard make pair function, and it's a templated function, so we tell it the datatype before our key and the datatype for our value. Then we provide the actual key and value as arguments to the function when we call it. These three lines of code are adding a score for Joe of 100, a score for Bob of 9,001, and they're unfortunately less adept brother JoeBob has a high score of one in this particular game. Will see an upcoming lecture why using the make_pair function can actually be a helpful way to add a key value pair to the map. If your map is simple like this, we can do the following. We can say HighScores, Harry, equal 42. For a simple unordered map with a simple key value pairs, it's also reasonable to add a key value pair to the map by just using this syntax where this is the key and this is the value. Then we'll prompt for and get a gamer tag from the user. Now, given the gamer tag that the user provided, we'll look up in our unordered map using the gamer tag. They provide it as a key. If there's a key value pair that corresponds to that key in the map, then we'll provide the high score for that gamer tag. If not, we'll print an error message that says, there's no high score for that gamer tag. One really effective way to find out if the map contains a particular key is to call the count function on the map and pass in the key that we want to check for and the count function will return how many times the key appears in the map. There could actually only be two numbers. There can be zero or there can be one. Maps don't allow duplicate keys. You can never have two or more key value pairs with the same key, but you might have zero if there's no key value pair with that key, or you might have one if there is a key value pair for that key. We can just get that count and then compare to one, and if the count is one, then we did find a key value pair in the map that has that key, so we can access the value, we can use at, like this, we can use the square brackets, like you saw me do above. Either way works fine. Then if the count function returned to zero, then we'll print no score for that gamer tag. I'll test with all the gamer tags that are in the map. A 100 for Joe, 9,001 for Bob, JoeBob only has one, and remember I added Harry, Harry has 42. But if I enter a different name like this, I get no a high score for that particular gamer tag because there was no key value pair in the map. To recap, in this lecture you learned that maps hold key-value pairs, we worked through an example using an unordered map, and you also learned how to use the count function to determine whether or not a map contains a particular key.