most cpu efficient way of accomplishing this

  • From: "Littlefield, Tyler" <tyler@xxxxxxxxxxxxx>
  • To: programmingblind@xxxxxxxxxxxxx
  • Date: Tue, 10 May 2011 12:29:08 -0600

Hello all:
I have a quick question.
In my game engine, I want to keep things modularized. This means that I am using components and modules to add features that do not directly fall within the core and actual mechanics of a barebones engine.

That said, I have a problem. I want to allow components and/or modules to register prompt handlers. Essentially all a prompt is is what the player sees when the mud outputs a chunk of text. You can make your prompt show hp, max hp, game time, etc etc. Rather than make everyone go to a specific file and just add their prompt though, i want to be able to add it to the world object, but this leads me to a question. I want to use the most efficient way of doing this. My current idea is something like this:
std::map<char, boost::function<std::string (void)> > _prompts;
But the std::map is not an actual hashtable, so this would be slow. It is just a collection of std::pairs. As this is being ran each and every time something gets sent to the player, I want to make it as fast as possible, so ideas would be welcome. Is there a standard way of doing this? I'd rather not have to write my own hash table just for this. I know about hash_map, but it isn't in the standard, which means not everyone will have it.

--

Take care,
Ty
my website:
http://tds-solutions.net
my blog:
http://tds-solutions.net/blog
skype: st8amnd127
“Programmers are in a race with the Universe to create bigger and better 
idiot-proof programs, while the Universe is trying to create bigger and better
idiots.  So far the Universe is winning.”
“If Java had true garbage collection, most programs would delete themselves upon 
execution.”

__________
View the list's information and change your settings at //www.freelists.org/list/programmingblind

Other related posts:

  • » most cpu efficient way of accomplishing this - Littlefield, Tyler