[MUD-Dev] Re: Question on c++ switch optimization, and parsers in general.
greear at cyberhighway.net
Mon Feb 8 19:25:50 New Zealand Daylight Time 1999
Ola Fosheim Gr=F8stad 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 keyw=
> at compile time then you might want to look into programs that can come=
> with a perfect hash-function for you. A perfect hashfunction is a funct=
> that takes a string and returns a unique number for your N keywords in =
> 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 at cyberhighway.net) http://www.primenet.com/~greear=20
Author of ScryMUD: mud.primenet.com 4444 (Released under GPL)
More information about the MUD-Dev