What is the difference between HashMap and HashTable?

Technology CommunityCategory: Hash TablesWhat is the difference between HashMap and HashTable?
VietMX Staff asked 3 years ago
Problem

I have seen people using these terms interchangeably for the same concept. Does it have no difference at all purely in context of data structures?

In Computing Science terminology, a map is an associative container mapping from a key to a value. In other words, you can do operations like “for key K remember value V” and later “for key K get the value”. A map can be implemented in many ways – for example, with a (optionally balanced) binary tree, or a hash table, or even a contiguous array of structs storing the key/value.

hash table is a structure for storing arbitrary data, and that data does not necessarily consist of a separate key and value. For example, I could have a hash table containing the values { 1, 10, 33, 97 }, which would be their own keys. When there is no value distinct from the key, this is sometimes known as a “set”, and with a hash table implementation a hash set.

So, a hash table stores elements, each of which need not consist of distinct key and value components, but if it does then it’s also a hash map.