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

Ben Greear greear at cyberhighway.net
Mon Feb 8 19:25:50 New Zealand Daylight Time 1999


Ola Fosheim Gr=F8stad wrote:
>=20
> Ben Greear wrote:
>=20
> > 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.
>=20
> Maybe I am interpreting "keywords" wrong here, but if you know the keyw=
ords
> 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 funct=
ion
> 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.


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

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




More information about the MUD-Dev mailing list