[Home] [Groups] - Message: [Prev in Group] [Next in Group]
9555: [MUD-Dev] Re: Question on c++ switch optimization, and parsers in general.
[Full Header] [Plain Text]
From: Ola Fosheim Grøstad <olag@ifi.uio.no>
Newsgroups: nu.kanga.list.mud-dev
Date: Mon, 08 Feb 1999 17:46:50 +0100
References: [1]
Organization: Kanga.Nu
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.
--
Ola Fosheim Groestad,Norway http://www.stud.ifi.uio.no/~olag/