Sequence container (C++)
Group of standard library class templates / From Wikipedia, the free encyclopedia
Dear Wikiwand AI, let's keep it short by simply answering these key questions:
Can you list the top facts and stats about Sequence container (C++)?
Summarize this article for a 10 year old
In computing, sequence containers refer to a group of container class templates in the standard library of the C++ programming language that implement storage of data elements. Being templates, they can be used to store arbitrary elements, such as integers or custom classes. One common property of all sequential containers is that the elements can be accessed sequentially. Like all other standard library components, they reside in namespace std.
This article may require cleanup to meet Wikipedia's quality standards. The specific problem is: See talk. (December 2011) |
The following containers are defined in the current revision of the C++ standard: array
, vector
, list
, forward_list
, deque
. Each of these containers implements different algorithms for data storage, which means that they have different speed guarantees for different operations:[1]
array
implements a compile-time non-resizable array.vector
implements an array with fast random access and an ability to automatically resize when appending elements.deque
implements a double-ended queue with comparatively fast random access.list
implements a doubly linked list.forward_list
implements a singly linked list.
Since each of the containers needs to be able to copy its elements in order to function properly, the type of the elements must fulfill CopyConstructible
and Assignable
requirements.[2] For a given container, all elements must belong to the same type. For instance, one cannot store data in the form of both char and int within the same container instance.