Languages
[Edit]
EN

Java - custom implementation of hash map, own string with equals and hash code (HashMap)

12 points
Created by:
Emrys-Li
580

In this hash map implementation we have SimpleString as key. SimpleString class was implemented only for purpose to explain how does hash map works internally.

SimpleString has own equals and hash code methods:

Those 2 methods were implemented to have user much better understanding of the entire concept of equals and hash code contract.

Hash Map is very important data structure in computer science. It depends on the programming language how do we call this data structure, very common synonyms are: hash map, hash table, dictionary, key value store, associative array.

Hash Map can be implemented in many different ways but the main functionality it should provide is very similar.

Simple hash map implementation

Edit

Output:

Test 1 - testing linked list used to store buckets

Edit

This linked list is used internally via our simple hash map as buckets.

Output:

Test 2 - put, get, remove, containsKey methods

Edit

Output:

Test 3 - put, get, remove, containsKey methods - more data

Edit

Output:

Test 4 - 2600 inserts to hash map of size 10

Edit

Output:

References

Edit
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join