Using STL hash tables to store data
The biggest difference between a map and a hash table is that while the map data structure is ordered, a hash table is unordered. Both use the same principle of key/value pairs. The worst case search complexity for an unordered map is O(N), as it is not ordered like a map, which has a complexity of O(log N).
Getting ready
For this recipe, you will need a Windows machine with a working copy of Visual Studio.
How to do it…
In this recipe, we will see how we can easily use the inbuilt template library provided for us by C++ to create complex data structures. After the complex data structure has been created, we can easily use it to store data and access it:
Open Visual Studio.
Create a new C++ project.
Add a source file called
Source.cpp
.Add the following lines of code to it:
#include <unordered_map> #include <string> #include <iostream> #include <conio.h> using namespace std; int main() { unordered_map<string, string> hashtable...