I'm just starting to play with hash tables, and I seem to have figured them out, but I was wondering if anyone could help me optimize my tables. All I know of them is what I remember from reading about them once several months ago, and I remember a little from a discussion on this list a long time ago. My application is a new magic system for circle. I'm designing a system that uses file-based spells, rather than code-based (not that it'll involve less code, but adding simple spells will be easier). I plan on having no less than 200-300 spells to get started, and could eventually have well over a thousand. Finding a spell by name in a list of 1000 strings is the problem. My solution is to use a hash table based on the first three letters in the spell name and the length of the name, and I'm using 200 as the hash modulus (if that's the correct term). If more than one spell falls under the same hash location, they're in a sequential linked list. My big question is: Is there a way to pick an optimal hash mod for this system? I remember someone on the list way back saying that prime numbers should be used, but I'm not sure why. I know I can optimize by repetitive building of the table with various values, but if someone could make some sense of the prime number idea, I'd appreciate it. Uh, I hope I didn't just ask a FAQ question. Sam +-----------------------------------------------------------+ | Ensure that you have read the CircleMUD Mailing List FAQ: | | http://cspo.queensu.ca/~fletcher/Circle/list_faq.html | | Or send 'info circle' to majordomo@cspo.queensu.ca | +-----------------------------------------------------------+
This archive was generated by hypermail 2b30 : 12/18/00 PST