当实施一个 std::stack
有几个选项,例如:
// stack with default underlying deque
std::stack< int > intDequeStack;
// stack with underlying vector
std::stack< int, std::vector< int > > intVectorStack;
// stack with underlying list
std::stack< int, std::list< int > > intListStack;
Run Code Online (Sandbox Code Playgroud)
std::stack
当我从中得到的只是相同的操作“push、pop 和 top”时,我从在不同的容器上定义有什么优点和缺点?
换句话说:一堆双端队列和一堆向量和一堆列表之间有什么区别,为什么我要选择双端队列以外的任何东西?