Re: Hash table formula help.

angus@EDGIL.CCMAIL.COMPUSERVE.COM
Date: 08/11/97


     Quote ------>
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.
     <------ Quote

     hmmm... a couple of thing to be aware of first... you message didn't
     indicate that you took them into account.
     1) gotta try the specials 1st.
     2) the directions depend on their placement.  unless you fix this by
     having it based off the SCMD_ of the command be VERY careful.

     ok... now to the good part... I don't think what you want here is a
     hash table in the pure sense (if there is one.)  what you want is a
     search tree.  something like:

     a ---- aa
       \--- ab
       \--- ac ---- aca
               \--- acb

     and so on until you think you have gotten deep enough in the list.
     also, you SHOULD NOT have any one letter commands.  with is_abbrev to
     take care of it for you, why do this to yourself? each of these can be
     an array of pointers char *command[26]; each pointing off to their own
     array.   don't forget null checks, 2 or 3 letter commands, and all
     that fun stuff.

     IMHO, I like the other system better. (maybe) allows me to stick all
     the socials at the end.  be very careful that qui come before quit and
     shutdow comes before shutdown and things like that.

     --Angus


     +------------------------------------------------------------+
     | 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