应该不推荐使用std :: list吗? [英] Should std::list be deprecated?

查看:259
本文介绍了应该不推荐使用std :: list吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据Bjarne Stroustrup的幻灯片,他的 std :: list中插入和删除 code>在现代硬件上效率极低:

According to Bjarne Stroustrup's slides from his Going Native 2012 keynote, insertion and deletion in a std::list are terribly inefficient on modern hardware:


大量插入和删除大量节拍列表

Vector beats list massively for insertion and deletion

如果这是真的, std :: list 会留下什么用例?

If this is indeed true, what use cases are left for std::list? Shouldn't it be deprecated then?

推荐答案

向量和列表解决不同的问题。 List提供了保证迭代器不会因为插入和删除其他元素而失效。向量不能保证。

Vector and list solve different problems. List provides the guarantee that iterators never become invalidated as you insert and remove other elements. Vector doesn't make that guarantee.

它不是所有的性能。所以答案是否定的。不应该弃用列表。

Its not all about performance. So the answer is no. List should not be deprecated.

编辑除此之外,C ++不是专为现代硬件设计的。它的目的是在比那更广泛的硬件上有用。我是金融行业的程序员,我使用C ++,但其他领域,如嵌入式设备,可编程控制器,心肺机和无数其他领域同样重要。 C ++语言不应该仅仅根据某些域的需要和某些类别的硬件的性能来设计 。只是因为可能不使用列表并不意味着应该从语言中弃用。

Edit Beyond this, C++ isn't designed to work solely on "modern hardware." It is intended to be useful across a much wider range of hardware than that. I'm a programmer in the financial industries and I use C++, but other domains such as embedded devices, programmable controllers, heart-lung machines and myriad others are just as important. The C++ language should not be designed solely with the needs of certain domains and the performance of certain classes of hardware in mind. Just because I might not use a list doesn't mean it should be deprecated from the language.

这篇关于应该不推荐使用std :: list吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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