May a hashtable store its keys in C++?

I have learned multiple languages, but It is the first time I have realized that some C++ books implements its HashTables without storing the key, only the value. I understand that due design specifications it is valid but I still have the question.

Is mandatory for a C++ hashtable to be implemented to only store values ?

Edit:

From this question

And this book: M. Weiss Allen, Data Structures and Algorithm Analysis in C++. Addison-Wesley, 2014. pag 197.

Upvotes: 0

Views: 190

Answers (1)

Somebody
Somebody

Reputation: 347

What you described are 2 different kinds of tables. One is a list, the other is a key-value-pair.

They hash tables you are familiar with are unordered_map in the standard library. The other one is an unordered_set. They have difference use-cases. Certainly, since both use hash functions, both can be called hash tables.

Upvotes: 2

Related Questions