xviserra added hashing

pull/1188/head
sameer 2023-05-15 12:31:37 +05:30
parent af47764be0
commit e36f61ff8f
1 changed files with 27 additions and 0 deletions

View File

@ -0,0 +1,27 @@
# Hashing in C++
## Introduction
Hashing is the process of converting any data into a fixed-size string of characters. It is used to index and retrieve items in a database because it is faster than searching through all the items in the database.
## Steps
1. Include the unordered_map header file.
2. Create an instance of the unordered_map.
3. Insert key-value pairs into the unordered_map.
4. Retrieve values from the unordered_map.
## Examples
```cpp
#include <iostream>
#include <unordered_map>
int main() {
std::unordered_map<std::string, int> myMap;
myMap["John"] = 25;
myMap["Jane"] = 30;
std::cout << "John is " << myMap["John"] << " years old." << std::endl;
return 0;
}