Skip to content

Instantly share code, notes, and snippets.

@vaishaks
Created July 29, 2014 18:11
Show Gist options
  • Save vaishaks/3ef752bb63300ce4f296 to your computer and use it in GitHub Desktop.
Save vaishaks/3ef752bb63300ce4f296 to your computer and use it in GitHub Desktop.
Using a hashtable in C++
#include "stdafx.h"
#include <iostream>
#include <string>
#include <unordered_map>
#include <conio.h>
using namespace std;
int main()
{
unordered_map<string, string> hashTable;
hashTable["foo"] = "bar";
hashTable.insert(pair<string, string>("vaishak", "salin"));
cout<<hashTable["foo"]<<" "<<hashTable["vaishak"]<<endl;
for (auto i = hashTable.begin(); i != hashTable.end(); ++i) {
cout<<i->first<<" "<<i->second<<endl;
}
_getch();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment