Can C++ std::stack handle more than 10k int items? And how about its performance?
Can C++ std::stack handle more than 10k int items? And how about its performance?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The performance depends on the underlying container used. As already mentioned,
stackis an adapter, the underlying container can bedeque(the default), orvector, orlist(all instdnamespace).Following is an example of performance comparison. As the type to be stored is not clearly mentioned in the question, I am assuming it to be unsigned int. Feel free to change it per your requirements. The example constructs a stack of 100K items.
Contents of
stack.cppExecution comparison:
The above numbers are result of single run. To achieve statistically significant numbers run each variation large number of times, and observe the mean and standard deviation.
Apparently,
dequeandvectorresults in similar performance, whereaslistis worse.