我有点困惑,谁能解释一下这些容器类型之间的主要区别:
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/