Skip to main content
GameDev.net gamedev.net
🔒 Locked

[C++] Do std::stack and std::queue poll their elements?

Started by someboddy Mar 24, 2010 at 10:43 AM 1 replies 1.1k views
Original Post
someboddy
someboddy
Or do they allocate/release memory each time you push/pop?
-----------------------------------------Everyboddy need someboddy!
stonemetal
stonemetal
It depends. The stack and queue are container adapters. You have to provide an underlying implementation that will control how memory is used. Give it a vector and it will pool memory. Give it a list and it won't. By default it uses the deque which is somewhere between a list and a vector on memory use. It allocates in pages and releases pages when they aren't necessary any more.
someboddy
someboddy
OK, thanks!
-----------------------------------------Everyboddy need someboddy!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.