Re: Hash table formula help.

From: Sammy (samedi@DHC.NET)
Date: 08/10/97


On Sat, 9 Aug 1997, Ryan Linn wrote:

> Hello,
>    I'm trying to decide on a good formula for a command list hash table.
> While I know the basics of hash tables, I'm trying to figure out the most
> effective way of hashing things.  My first reaction was to just hash the
> first character and insert/search by that.  But then there would still be
> 30 + compares for certain commands on my mud.  But if you hashed first
> two characters, then any 1 letter commands could be lost.  So.. back to
> square 1.Any suggestions,or if you have a formula that you have found to work,
>  it would be greatly appreciated.

It depends on how your hash formula works.  The arg variable in
command_interpreter() is always going to have at least two useable
characters.  In the case of the single-char commands, it breaks them apart
and adds a null terminator to arg, so an example would be '\'' '\0' for
the "say" abbreviation.  If you're optimizing on the assumption that all
command letters will be either alphabetic or punctuation you'll have to
add an extra case, but I don't think it should cause much trouble.

Sam


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/08/00 PST