tags:

views:

107

answers:

3

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

map
list
set
array

thanks in advanca(I'm asking about C++)

+5  A: 

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.

Péter Török
How are arrays not generic?
FredOverflow
+1  A: 

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.
Brian R. Bondy
+1  A: 

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

thatsalok