#include <string>
#include <vector>
usingnamespace std;
#define NUM_BUCKETS 1001
#ifndef HASHTABLE_H_INCLUDED
#define HASHTABLE_H_INCLUDED
//HashTable.h, the specification file for the class HashTable
class Entry {
public:
string key;
string value;
};
class HashTable {
public:
// Add a key-value pair to hash table
void insert(string key, string value);
// Return the value associated with the given key in hash table.
// Return empty string if key not found.
string find(string key);
// Print out the number of elements in each of the buckets
void printBucketSizes();
private:
unsignedint hashFunction(const std::string& str);
vector<Entry> table[NUM_BUCKETS]; // an array of vectors<Entry>
};
#endif // HASHTABLE_H_INCLUDED
Sounds like you're doing "chaining" but with vectors. Hash the key to find the bucket it will go into. Look through the vector for an equal key. If one is found, overwrite it with the new data. If none is found, append the entry to the vector (push_back).