Hacker News new | ask | show | jobs
by quinnftw 3445 days ago
A few issues with this implementation:

Is it really nessecary to allocate all of the hash buckets up front? Why not initialize them to null and then allocate them as you need?

Why not use some kind of managed container like std vector to store the hash buckets? This removes the need to do explicit memory management.

Why not use std forward_list instead of rolling your own linked list? Again, this will reduce the amount of code and save you from having to do manual memory management

1 comments

Thank you very much for your review comments. Please find my answers below. All the hash buckets are allocated upfront so that there is no need for a global map. If I want to allocate the hash buckets later, there will be a need to take a hashmap-level-lock, which will hamper the concurrency of the map. Yes, using the std containers will make life easy. I was trying to have my own data structure in place, but there is no particular reason for it. I might move to the std containers in later version.