From 9c93e23115623bbe846de25eb10546589b5ee36c Mon Sep 17 00:00:00 2001 From: Amruta Kothawade <116087736+Amruta7203@users.noreply.github.com> Date: Mon, 24 Jun 2024 18:24:37 +0530 Subject: [PATCH 1/2] Update 01_Containers_in_STL.md --- .../01_Containers_in_STL.md | 56 ++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/docs/cpp/10_Standard_Template_Library/01_Containers_in_STL.md b/docs/cpp/10_Standard_Template_Library/01_Containers_in_STL.md index 7438ea33e..f37d7cb93 100644 --- a/docs/cpp/10_Standard_Template_Library/01_Containers_in_STL.md +++ b/docs/cpp/10_Standard_Template_Library/01_Containers_in_STL.md @@ -12,4 +12,58 @@ tags: c++ STL containers ] 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. ---- \ No newline at end of file +--- + +# STL Containers + +## Introduction + +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. + +## Types of STL Containers + +Vector - Vector is a class that creates a dynamic array allowing insertions and deletions at the back. + Header File: + +List - List is the sequence containers that allow the insertions and deletions from anywhere. + Header File: + +Deque - Deque is the double ended queue that allows the insertion and deletion from both the ends. + Header File: + +Set - Set is an associate container for storing unique sets. + Header File: + +Multiset - Multiset is an associate container for storing non- unique sets. + Header File: + +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). + Header File: + +Multimap - Multimap is an associate container for storing key- value pair, and each key can be associated with more than one value. + Header File: + +Stack - It follows last in first out(LIFO). + Header File: + +Queue - It follows first in first out(FIFO). + Header File: + +Priority-queue - First element out is always the highest priority element. + Header File: + + +## Choosing the Right Container + +Here are some general guidelines for choosing the appropriate container: + +1. Sequential containers +are used to store elements in a linear order. They include arrays, vectors, deques, lists, and forward lists. + +2. Associative containers +are used to store elements in a key-value relationship. They include maps, multimaps, sets, and multisets. + +3. Container adapters +provide a different interface to an existing container. They include stacks, queues, and priority queues. + +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. From d10058ac8f6ae6173cf89f892919b7f312484327 Mon Sep 17 00:00:00 2001 From: Ajay Dhangar <99037494+Ajay-Dhangar@users.noreply.github.com> Date: Mon, 24 Jun 2024 21:04:53 +0530 Subject: [PATCH 2/2] Update 01_Containers_in_STL.md --- .../01_Containers_in_STL.md | 51 +++++++++---------- 1 file changed, 23 insertions(+), 28 deletions(-) diff --git a/docs/cpp/10_Standard_Template_Library/01_Containers_in_STL.md b/docs/cpp/10_Standard_Template_Library/01_Containers_in_STL.md index f37d7cb93..924c1dafa 100644 --- a/docs/cpp/10_Standard_Template_Library/01_Containers_in_STL.md +++ b/docs/cpp/10_Standard_Template_Library/01_Containers_in_STL.md @@ -14,56 +14,51 @@ tags: 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. --- -# STL Containers - ## Introduction 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. ## Types of STL Containers -Vector - Vector is a class that creates a dynamic array allowing insertions and deletions at the back. - Header File: +- **Vector:** Vector is a class that creates a dynamic array allowing insertions and deletions at the back. + Header File: `` -List - List is the sequence containers that allow the insertions and deletions from anywhere. - Header File: +- **List:** List is the sequence containers that allow the insertions and deletions from anywhere. + Header File: `` -Deque - Deque is the double ended queue that allows the insertion and deletion from both the ends. - Header File: +- **Deque:** Deque is the double ended queue that allows the insertion and deletion from both the ends. + Header File: `` -Set - Set is an associate container for storing unique sets. - Header File: +- **Set:** Set is an associate container for storing unique sets. + Header File: `` -Multiset - Multiset is an associate container for storing non- unique sets. - Header File: +- **Multiset:** Multiset is an associate container for storing non- unique sets. + Header File: `` -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). - Header File: +- **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). + Header File: `` -Multimap - Multimap is an associate container for storing key- value pair, and each key can be associated with more than one value. - Header File: +- **Multimap:** Multimap is an associate container for storing key- value pair, and each key can be associated with more than one value. + Header File: `` -Stack - It follows last in first out(LIFO). - Header File: +- **Stack:** It follows last in first out(LIFO). + Header File: `` -Queue - It follows first in first out(FIFO). - Header File: +- **Queue:** It follows first in first out(FIFO). + Header File: `` -Priority-queue - First element out is always the highest priority element. - Header File: +- **Priority-queue:** First element out is always the highest priority element. + Header File: `` ## Choosing the Right Container Here are some general guidelines for choosing the appropriate container: -1. Sequential containers -are used to store elements in a linear order. They include arrays, vectors, deques, lists, and forward lists. +1. Sequential containers are used to store elements in a linear order. They include arrays, vectors, deques, lists, and forward lists. -2. Associative containers -are used to store elements in a key-value relationship. They include maps, multimaps, sets, and multisets. +2. Associative containers are used to store elements in a key-value relationship. They include maps, multimaps, sets, and multisets. -3. Container adapters -provide a different interface to an existing container. They include stacks, queues, and priority queues. +3. Container adapters provide a different interface to an existing container. They include stacks, queues, and priority queues. 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.