Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
C++ 中顺序容器适配器(即堆栈、队列)的目的是什么?
谢谢。
它们提供了一个更窄的接口来强制执行额外的不变量,因此当您希望保留这些不变量时使用起来更安全。
您的问题的最佳答案是阅读以下书籍:
有效的 STL
但是,如果您想要一个快速而肮脏的答案:堆栈和队列不仅可以模拟现实世界的对象,例如程序堆栈和进程队列,它们也是随机插入和删除操作的最佳选择。