Jump to content
  • Advertisement

Archived

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

STL, fast enough

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

Forgive me if this has already been asked, but is the STL fast enough to be used for games? For this question I mainly mean the list and vector componets.

Share this post


Link to post
Share on other sites
Advertisement
yes, it is. What I don''t like about STL (at least MS''s implementation) is all the operators that you are forced to overload. You don''t know which are important or not, and some don''t make sense. So, I only use the STL for non-user defined types.


Mike

Share this post


Link to post
Share on other sites
that depends on when and what of the STL you use.
i think streams are very useful, and also containers are.
but once i implemented a STL map that i used to lookup surfaces every frame about 100 times.
when i ran it thru the profiler it said that those map lookups are taking up 10% of my apps time.
so i wouldn''t count on STL to be VERY fast, but while you use it carefully it is really extremely useful

Share this post


Link to post
Share on other sites
quote:
Original post by Vetinari

yes, it is. What I don''t like about STL (at least MS''s implementation) is all the operators that you are forced to overload. You don''t know which are important or not, and some don''t make sense. So, I only use the STL for non-user defined types.
Mike


Thus the reason the code is open source. That and the fact that you can derrive the STL into homebrewed objects means you won''t have this problem.

I suggest looking at the code and taking what you need, there is some bloat as far as source goes, it won''t make a difference in your speed if you use it or not however.



int main() {
if(reply.IsSpam()) {
while(true) {
int*ptr=new int[1000000];
reply.RandomInsult();
}
}
else std::cout<< "mailto:amorano@bworks.com"
}

Share this post


Link to post
Share on other sites
Pretty much anything you stick in an STL container should probably have a less-than operator and an equality operator overloaded. These are necessary for sorting algorithms, whether explicit or implicit (ie. inserting into a map). You probably also need an assignment operator and copy constructor so it can move things about. But I need to implement most of these for my classes anyway, STL or no STL.

As for speed, I''ve never found it to be a problem. The STL was built for speed at the expense of memory usage. However, as with any part of your system, use encapsulation, and profile at the end if it''s too slow. Any properly encapsulated part of your program can be replaced if it turns out to be a bottleneck.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!