Skip to content
This repository has been archived by the owner on Nov 8, 2023. It is now read-only.

Added at method in unordered maps #656

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions unordered_map/at.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# at

**Description :** This function is used to modify values by using key of respective value.

**Example** :

```cpp
// Demonstrates at()
#include <iostream>
#include <string>
#include <unordered_map>

int main(){
//Initializing a map with values as specified:
std::unordered_map<std::string, int> mymap = {
{ "First", 100},
{ "Second", 200},
{ "Third", 300 }
};

//Updating values with the help of at() method
mymap.at("First") = 50;
mymap.at("Second") += 500;
mymap.at("Third") = mymap.at("First") + 950;

//Printing all three values
for (auto& x: mymap){
std::cout << x.first << ": " << x.second << std::endl;
}

return 0;
}

```

**[Run Code](https://rextester.com/VEEQ37866)**