开发者

difference between containers

I'm a little bit confused, can somebody please explain the main difference between those types of containers:

map
list
set
array
开发者_C百科

I'm asking about 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.

Arrays are also a kind of sequence containers, just much lower level than list. Their size is fixed, they don't manage memory dynamically and aren't generic. They are inherited from C.


SGI has a good tutorial and documentation on STL for the map, list and set. For arrays any basic C or C++ tutorial will cover this information.

  • map is a container which maps a key to a value, think of it like a lookup table.
  • list is a container which is a sequence that supports both forward and backwards traversal
  • set is a container which stores a list of unique items
  • array is a consecutive block of memory which any item is accessible in constant time but cannot grow after its initial size.


http://www.cppreference.com/wiki/ : you can consider it!"

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜