Course Object Oriented Programming

Containers

Course's Page 17 min Text by
User Image
Allan Garcia

In this class, we will see a bit about containers, that is, structures that can store data.

The containers of STL

By accessing the [Reference] website (https://www.cplusplus.com/reference/stl/), we can see what containers are available for our use.

They are, depending on their functionality, separated by categories. See these categories and some examples, briefly described, of each one:

  • Containers of sequence: have their elements stored in the order we specify.

-- *Array: very similar to the array of C, which we already know (the one declared using the brackets), has some extra amenities, like storing its own size.

-- Vector: represents arrays that can change size, allowing the insertion and removal of elements. We will see a bit more about them still in this class.

-- Deque: known as two-end queue, allows fast insertions and removals at the beginning and end of the sequence.

  • *Associative containers have their elements stored in a predefined order (for example, in ascending order).

-- *Map: also called a dictionary, it consists of a key-* value* pair. In short, the key will be used to access the value of a given element.