This is a custom HashMap implementation in JavaScript, providing efficient key-value storage with collision handling and dynamic resizing. This project was done as part of The odin project https://www.theodinproject.com/lessons/javascript-hashmap
- Implements standard HashMap methods
- Collision resolution using chaining
- Dynamic bucket resizing based on load factor
set(key, value)
: Add or update a key-value pairget(key)
: Retrieve value for a given keyhas(key)
: Check if a key existsremove(key)
: Remove a key-value pairlength()
: Get number of entriesclear()
: Remove all entrieskeys()
: Get all keysvalues()
: Get all valuesentries()
: Get all key-value pairs
Clone the repository and import the HashMap class into your project.
const map = new HashMap(16, 0.75);
map.set('apple', 'red');
map.get('apple'); // returns 'red'
map.has('apple'); // returns true
- O(1) average case for most operations
- Handles collisions with chaining
- Automatic resizing when load factor exceeded
Contributions welcome! Please submit pull requests or open issues.