简体   繁体   中英

Hashtable/Map: where to start

I am looking to make a function that takes a string and returns a value that is in an dynamic's array range, basically, a dynamic hash-table, But I'm rather confused on where to start, I have the vector down, but I don't know which hashing function would be good for perhaps runtime performance -- I want it to be fast and with no collisions, therefore, I would love if you could share some resources on candidate implementations or algorithms

Thank you.

Well, there is alot of factors to have in consideration. One is the size of the hash table. A hash table is only good if there is no colisions so a big prime number will do, however if the number is to big u will waste alot of memory, you have to take in consideration how much data you are expecting. Same case happens if your prime is to low, u are force to create remake the hash.

There is 2 solution that im aware of to prevent the colisions: U can create another hash or array list inside of your hash everytime a collision happens.

Or u can also everytime a colision happen try to put that info in the next free space of your hash table.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM