MUD-Dev
mailing list archive

Other Periods  | Other mailing lists  | Search  ]

Date:  [ Previous  | Next  ]      Thread:  [ Previous  | Next  ]      Index:  [ Author  | Date  | Thread  ]

[MUD-Dev] Re: Question on c++ switch optimization, and parsers in general.



Ola Fosheim Grøstad wrote:
> 
> Ben Greear wrote:
> 
> > Basically, I'll have a bunch of classes hashed into an array
> > that will contain the keywords mapped to an enum.
> >
> > Now, I get the enum, and then I need to call the various commands
> > that the enum maps to.
> 
> Maybe I am interpreting "keywords" wrong here, but if you know the keywords
> at compile time then you might want to look into programs that can come up
> with a perfect hash-function for you. A perfect hashfunction is a function
> that takes a string and returns a unique number for your N keywords in the
> range [0..N]. Your unix system (if you use one) probably comes with a
> program to generate a perfect hashfunction.

I'd do that, but I want the user to be able to abbreviate any command.
I couldn't figure out a way to hash and still get that feature.


> 
> --
> Ola Fosheim Groestad,Norway      http://www.stud.ifi.uio.no/~olag/

-- 
Ben Greear (greear#cyberhighway,net)  http://www.primenet.com/~greear 
Author of ScryMUD:  mud.primenet.com 4444        (Released under GPL)
http://www.primenet.com/~greear/ScryMUD/scry.html




Other Periods  | Other mailing lists  | Search  ]