You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/cpp/10_Standard_Template_Library/01_Containers_in_STL.md
+23-28Lines changed: 23 additions & 28 deletions
Original file line number
Diff line number
Diff line change
@@ -14,56 +14,51 @@ tags:
14
14
description: In this tutorial, we'll explore STL containers in C++. We'll cover the different types of Standard Template Library containers, including vectors, lists, deques, sets, maps, and more. You'll learn how to choose the appropriate container for your needs and how to use their various functions and methods. Understanding STL containers is essential for effective data management and manipulation in C++ programs, providing you with powerful tools to handle collections of data efficiently.
15
15
---
16
16
17
-
# STL Containers
18
-
19
17
## Introduction
20
18
21
19
Containers can be described as the objects that hold the data of the same type. Containers are used to implement different data structures for example arrays, list, trees, etc.
22
20
23
21
## Types of STL Containers
24
22
25
-
Vector - Vector is a class that creates a dynamic array allowing insertions and deletions at the back.
26
-
Header File: <vector>
23
+
-**Vector:** Vector is a class that creates a dynamic array allowing insertions and deletions at the back.
24
+
Header File: `<vector>`
27
25
28
-
List - List is the sequence containers that allow the insertions and deletions from anywhere.
29
-
Header File: <list>
26
+
-**List:** List is the sequence containers that allow the insertions and deletions from anywhere.
27
+
Header File: `<list>`
30
28
31
-
Deque - Deque is the double ended queue that allows the insertion and deletion from both the ends.
32
-
Header File: <deque>
29
+
-**Deque:**Deque is the double ended queue that allows the insertion and deletion from both the ends.
30
+
Header File: `<deque>`
33
31
34
-
Set - Set is an associate container for storing unique sets.
35
-
Header File: <set>
32
+
-**Set:**Set is an associate container for storing unique sets.
33
+
Header File: `<set>`
36
34
37
-
Multiset - Multiset is an associate container for storing non- unique sets.
38
-
Header File: <set>
35
+
-**Multiset:** Multiset is an associate container for storing non- unique sets.
36
+
Header File: `<set>`
39
37
40
-
Map - Map is an associate container for storing unique key-value pairs, i.e. each key is associated with only one value(one to one mapping).
41
-
Header File: <map>
38
+
-**Map:** Map is an associate container for storing unique key-value pairs, i.e. each key is associated with only one value(one to one mapping).
39
+
Header File: `<map>`
42
40
43
-
Multimap - Multimap is an associate container for storing key- value pair, and each key can be associated with more than one value.
44
-
Header File: <map>
41
+
-**Multimap:** Multimap is an associate container for storing key- value pair, and each key can be associated with more than one value.
42
+
Header File: `<map>`
45
43
46
-
Stack - It follows last in first out(LIFO).
47
-
Header File: <stack>
44
+
-**Stack:**It follows last in first out(LIFO).
45
+
Header File: `<stack>`
48
46
49
-
Queue - It follows first in first out(FIFO).
50
-
Header File: <queue>
47
+
-**Queue:** It follows first in first out(FIFO).
48
+
Header File: `<queue>`
51
49
52
-
Priority-queue - First element out is always the highest priority element.
53
-
Header File: <queue>
50
+
-**Priority-queue:**First element out is always the highest priority element.
51
+
Header File: `<queue>`
54
52
55
53
56
54
## Choosing the Right Container
57
55
58
56
Here are some general guidelines for choosing the appropriate container:
59
57
60
-
1. Sequential containers
61
-
are used to store elements in a linear order. They include arrays, vectors, deques, lists, and forward lists.
58
+
1. Sequential containers are used to store elements in a linear order. They include arrays, vectors, deques, lists, and forward lists.
62
59
63
-
2. Associative containers
64
-
are used to store elements in a key-value relationship. They include maps, multimaps, sets, and multisets.
60
+
2. Associative containers are used to store elements in a key-value relationship. They include maps, multimaps, sets, and multisets.
65
61
66
-
3. Container adapters
67
-
provide a different interface to an existing container. They include stacks, queues, and priority queues.
62
+
3. Container adapters provide a different interface to an existing container. They include stacks, queues, and priority queues.
68
63
69
64
Understanding STL containers is essential for effective data management and manipulation in C++ programs, providing you with powerful tools to handle collections of data efficiently.
0 commit comments