Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

sprinter_trueno

lookuptables

This topic is 5731 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi there, I got two questions regarding lookup tables: 1. How do you fill one in a neat way if the contents don''t match any pattern ? ( Example: IndexTable[2][2][16] ) If it''s a part of a class and let''s say all the instances wanna use this table... 2. What is a good approach to initialize it ? So far my ideas were the following: 1. The array is ''static'' in the class 2. A static function like InitTable()that is called before the first instance. 3. Like 2. but the function is called in the constructor with a static flag to prevent further initialization. Somehow I don''t like those. Is there a better way ? Any comment appreciated. Lorenz

Share this post


Link to post
Share on other sites
Advertisement
int a[3][2] = {{1,2},{3,4},{5,6}};

If all instances wanna share it, you can do it with statics..

  
struct B {
static const A a[2];
};

const A B::a[2] = { A(1), A(2) };

Or maybe have InitTable() that eg. loads it from a file. Whatever you prefer.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!