Sign in to follow this  

C++ containers

This topic is 4015 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

I'm having a number of C++ problems that are quite a challenge. I can do this in C# blind folded yet I feel lost in C++. I'm making a function that will get called from a script file. The function will create objects on the heap. It will allow me to define by scripting the objects that get loaded to the game. In C# I would place the new objects into a List. C++ has several options (std, boost, etc) and in many cases people build their own linked lists. My object class will contain pointers to Irrlicht (the rendering engine I'm using )resources like textures and meshes So what would be the best container to use? Calin.

Share this post


Link to post
Share on other sites
You select containers based on the characteristics you need. vector is random access, low access overhead, good when elements are added or deleted from the end, sucks when adding or deleting from other places. list trades random access for more efficient insertions and deletions anywhere in the list. deque is basically vector with a bit of extra overhead to make insertions and deletions in the front as efficient as in the back, etc.

Figure out what you need from your container. We can't help you much until then.

Share this post


Link to post
Share on other sites
std, i.e. the STL, is the default built-in library. boost is an external library that'd you have to download and configure. I've always used the STL, people are a fan of boost. I'd start with the STL because it's, you know, standard. After that you should check out boost and see what it has to offer.

-me

Share this post


Link to post
Share on other sites

This topic is 4015 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this