Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any complexity difference between a std::vector used as a stack and a std::stack?

Tags:

c++

std

Like the title asks Is there any time or space difference between a std::vector used as a stack and a std::stack ?

like image 403
user2370139 Avatar asked Mar 09 '23 05:03

user2370139


1 Answers

A std::stack wraps another container. If the backing container of your stack is a std::vector, then no, there is no difference.

The default backing container is however a std::deque, which can have different storage and timing behaviour

See std::stack for details

like image 111
king_nak Avatar answered May 02 '23 20:05

king_nak