I'm going to create a stack of pointers to objects, and I need to implement an identifier with the best performance.
Those objects are custom classes.

I'm wondering what would be best for performance. Either of these two ways, or maybe a third better way?.

1) Making an std::map for the stack, with a string identifier.
2) Making an std::vector with just the pointer, and then loop through all the objects (which may be 50+, each containing a few kilobytes), and read object::name which would be a string too.

And again to mention, if theres a better way, please hint me :)

Thank you ahead! :D

Recommended Answers

All 4 Replies

This thread seems to be a good discussion of that topic.

I'm going to create a stack of pointers to objects

You might also want to take a look at std::stack and std::deque

Ok I'll be looking at that.


Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.