Difference between HashMap and HashTable exclusively in data structures

What is the difference between HashTable and HashMap solely in the context of data structures (and not in Java or any other language)?

I have seen people using these terms interchangeably for the same concept. Doesn't that make any difference purely in the context of data structures?

+15
source share
4 answers

In Computing Science terminology, a map is an associative mapping of containers from key to value. In other words, you can perform operations such as "for key K, remember the value of V", and then "for key K, get the value." A map can be implemented in different ways - for example, using a (possibly balanced) binary tree or hash table, or even a continuous array of structures that store a key / value.

A hash table is a structure for storing arbitrary data, and this 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 other than a key, this is sometimes called "set", and with a hash table implementation, it is called a "hash set".

So, the hash table stores the elements, each of which should not consist of separate components of the key and value, but if it does, it is also a hash map.

+15
source

The explanation between hashmap and hashtable is quite correct, since it is also suitable for the header of a string hash map implemented in strmap.c, where stringmap is a hash table for strings satisfying the key properties, value-structure. It says here:

 /* * strmap version 2.0.1<br> * * ANSI C hash table for strings. * * Version history: * 1.0.0 - initial release * 2.0.0 - changed function prefix from strmap to sm to ensure * ANSI C compatibility * 2.0.1 - improved documentation< * * strmap.c * * Copyright (c) 2009, 2011, 2013 Per Ola Kristensson. * * Per Ola Kristensson < pok21@cam.ac.uk > * Inference Group, Department of Physics * University of Cambridge * Cavendish Laboratory * JJ Thomson Avenue * CB3 0HE Cambridge * United Kingdom * * strmap is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * strmap is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with strmap. If not, see <http://www.gnu.org/licenses/>. */ #include "strmap.h" typedef struct Pair Pair; typedef struct Bucket Bucket; struct Pair { char *key; char *value; }; 
0
source

Here is how I understand it:
Hash table: what we call a concept in computer science
Hash Map: what it's called in Java
Hash Set (HashSet): the case when we care only about unique keys (or you can see it as a Hash Table, where we ignore the values, we just want to know what a unique key set is)

Or simply
Hash Table (CS) = HashMap (Java) = Dictionary (Python)
Hash Set (CS) = HashSet (Java) = Set (Python)

0
source

C has no built-in containers (other than arrays), so it depends on what they want to name. As for C, the HashMap vs. HashTable doesn't really matter.

One possible difference may be how the backup storage is created. A hash table can be a simple linear array of keys and values ​​indexed by a hash. The hash map can be a balanced tree, sorted by key, as well as a table that maps the hash to the node tree, which allows you to quickly and quickly (O (1)) search and the ability to move data in turn order.

Or it could be something completely different. Again, C does not have any built-in container for this kind of thing, so the names really mean nothing in the context of C.

-1
source

All Articles