Skip to content

Commit 7d1b927

Browse files
authored
Merge pull request #1 from Amruta7203/newBranch
Update 01_Containers_in_STL.md
2 parents bb0349b + 9c93e23 commit 7d1b927

File tree

1 file changed

+55
-1
lines changed

1 file changed

+55
-1
lines changed

docs/cpp/10_Standard_Template_Library/01_Containers_in_STL.md

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,58 @@ tags:
1212
c++ STL containers
1313
]
1414
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+
17+
# STL Containers
18+
19+
## Introduction
20+
21+
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+
23+
## Types of STL Containers
24+
25+
Vector - Vector is a class that creates a dynamic array allowing insertions and deletions at the back.
26+
Header File: <vector>
27+
28+
List - List is the sequence containers that allow the insertions and deletions from anywhere.
29+
Header File: <list>
30+
31+
Deque - Deque is the double ended queue that allows the insertion and deletion from both the ends.
32+
Header File: <deque>
33+
34+
Set - Set is an associate container for storing unique sets.
35+
Header File: <set>
36+
37+
Multiset - Multiset is an associate container for storing non- unique sets.
38+
Header File: <set>
39+
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>
42+
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>
45+
46+
Stack - It follows last in first out(LIFO).
47+
Header File: <stack>
48+
49+
Queue - It follows first in first out(FIFO).
50+
Header File: <queue>
51+
52+
Priority-queue - First element out is always the highest priority element.
53+
Header File: <queue>
54+
55+
56+
## Choosing the Right Container
57+
58+
Here are some general guidelines for choosing the appropriate container:
59+
60+
1. Sequential containers
61+
are used to store elements in a linear order. They include arrays, vectors, deques, lists, and forward lists.
62+
63+
2. Associative containers
64+
are used to store elements in a key-value relationship. They include maps, multimaps, sets, and multisets.
65+
66+
3. Container adapters
67+
provide a different interface to an existing container. They include stacks, queues, and priority queues.
68+
69+
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

Comments
 (0)