c++ - 容器之间的区别

标签 c++

我有点困惑,谁能解释一下这些容器类型之间的主要区别:

map
list
set
array

我问的是 C++。

最佳答案

http://cplusplus.com/reference/stl/

  • Maps are a kind of associative containers that stores elements formed by the combination of a key value and a mapped value.
  • Lists are a kind of sequence containers. As such, their elements are ordered following a linear sequence.
  • Sets are a kind of associative containers that stores unique elements, and in which the elements themselves are the keys.

数组也是一种序列容器,只是比list低很多。它们的大小是固定的,它们不动态管理内存并且不是通用的。它们继承自 C。

关于c++ - 容器之间的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3033885/

相关文章:

c++ - 将 BYTE* 转换为 wstring?

c++ - 为什么 Boost::multiprecision::sqrt(1) 返回 0?

c++ - Windows Vista 上 Qt 中的静态构建

c++ - 基于std::set的无序选择实现最终会重复

c++ - 我正在尝试设置几个不同的多维数组,但无法弄清楚为什么这不起作用

c++ - 从exe和dll访问静态库中的外部变量

c++ - 防止竞争条件

c++ - 将指向基类型的指针与派生类型的指针进行比较

c++ - 如何使用Qt Creator调试C++项目?

c++ - 在 C Linux 中通过套接字发送图像 (JPEG)