Realize HashMap

How to create a Hashmap in C from scratch?
What parameters to consider and how to test how good a hashmap is? Just like the benchmark test case you need to run before you say that the hash map is complete.
Well, if you know The basics behind them, then it shouldn’t be too difficult.

Usually, you create an array called “buckets”, which contains keys and values, and a list for creating links Optional pointer to.

When using keys to access the hash table, use a custom hash function to process the key, which will return an integer. Then take the modulus of the result, which is the array index or “bucket” Then use the stored key to check the unhashed key, and if it matches, find the correct location.

Otherwise, you have encountered a “conflict” and you must grab the list of links and compare the keys Until you match. (Note that some implementations use binary trees instead of linked lists for conflicts).

Look at the implementation of this fast hash table:

http://attractivechaos. awardspace.com/khash.h.html

How to create a Hashmap in C from scratch?
What parameters to consider and how to test how good a hashmap is? Just like the benchmark test cases you need to run before you say that the hash map is complete.

Well, if you know the basics behind them, it shouldn’t be too difficult

Usually, you create an array called “buckets”, which contains keys and values, and an optional pointer to create a linked list.

When using a key to access the hash table, use a custom hash function to process the key, which will return an integer. Then take the modulus of the result, which is the array index or the position of the “bucket”. Then use the stored key to check for unhashing If it matches, find the correct location.

Otherwise, you have encountered a “conflict” and you must grab the link list and compare the keys until you match. (Note that some implementations use binary trees Instead of linked lists for conflict).

Look at the implementation of this fast hash table:

http://attractivechaos.awardspace.com/khash.h.html

Leave a Comment

Your email address will not be published.