1#include <bits/stdc++.h>
11 vector<list<pair<int, int>>>
table;
28 void put(
int key,
int value)
31 for (
auto& p :
table[h])
37 table[h].emplace_back(key, value);
49 for (
const auto& p :
table[h])
63 table[h].remove_if([key](
const pair<int, int>& p) {
return p.first == key; });
72 int value = obj->
get(1);
73 cout << value << endl;
75 cout << value << endl;
78 cout << value << endl;
81 cout << value << endl;
int hash(int key)
Returns index of table used as hashtable with given key.
vector< list< pair< int, int > > > table
int get(int key)
Retrieves value of the key.
void remove(int key)
Retrieves valid list and removes entry for key-value pair.
void put(int key, int value)
Retrieves valid list and set/appends new value with given key.