为什么在C ++ std :: vector中没有pop_front方法? [英] Why there is no pop_front method in C++ std::vector?

查看:192
本文介绍了为什么在C ++ std :: vector中没有pop_front方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么在C ++中没有 pop_front 方法 std :: vector

Why there is no pop_front method in C++ std::vector?

推荐答案

因为 std :: vector 没有关于在前面插入元素的特殊功能,容器。每个容器提供的功能对该容器有意义。

Because a std::vector has no particular feature regarding inserting elements at the front, unlike some other containers. The functionality provided by each container makes sense for that container.

您可能应该使用 std :: deque

You probably should be using a std::deque, which is explicitly good at inserting at the front and back.

检查是否正确 此图

这篇关于为什么在C ++ std :: vector中没有pop_front方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆