You need to write a hash function in C ++, which for a key of type string will return a possible index:
h(key, m) = h(key, n, m) if i = 0: h(key, i, m) = 0 else: h(key, i, m) = (256 * h(key, i - 1, m) + key_i) % m) n - длина key The initHashList method, which creates and initializes an array of HashEntry type and returns a pointer to this array. During initialization, it sets the values: key - an empty string, value - (-1), used - false.
struct HashEntry{ std::string key; //the key of the entry bool used; //the value of the entry int value; //marks if the entry was used before }; And lastly, the insert method, which adds an entry to the hash list (accepts key, value)
std::unordered_set<int>. If this is a learning task, solve it yourself, otherwise you will not learn anything. - VladD