SlideShare a Scribd company logo
1 of 20
Standard Template Libraries
Krishna Prasad H 310621104076
Murali Krishnan N 310621104098
R. Rahul 31062110127
Presented by
Subject Code: 191CSC302T Subject Name: Object oriented with C++
EASWARI ENGINEERING COLLEGE
(Autonomous)
Ramapuram, Chennai – 600 089
16th November, 2022
Prithika R 310621104124
Kiruthika K 310621104073
CONTENTS
• Standard Template Libraries
• Containers
• Sequence Containers
• Associative containers
• Container Adapters
• Algorithms
• Iterators
STANDARD TEMPLATE LIBRARIES(STL)
• The Standard Template Library (STL) is a set of C++ template classes to provide common
programming data structures and functions such as lists, stacks, arrays, etc.
CONTAINERS
• A container is a holder object that stores a collection of other objects (its elements). They are
implemented as class templates, which allows great flexibility in the types supported as
elements.
SEQUENCE CONTAINERS
• Sequence containers implement data structures that can be accessed sequentially.
• This includes vectors, list,arrays, dequeue,arrays, forward list.
• Vectors are the same as dynamic arrays with the ability to resize itself automatically when
an element is inserted or deleted
ASSOCIATIVE CONTAINER
• It is a variable-sized Container that supports efficient retrieval of elements (values) based on
keys. It consists of 4 types
SET:
A set is an Associative container which contains
a sorted set of unique objects of type Key.
MULTISET:
Multisets are a type of associative containers
similar to the set, with the exception that multiple
elements can have the same values.
• Maps are associative containers that store
elements in a mapped fashion.
• Each element has a key value and a mapped
value. No two mapped values can have the
same key values.
MAPS: MULTIMAP:
• Multimap is similar to a map with the addition
that multiple elements can have the same
keys.
• Keeps all the keys in sorted order.
CONTAINER ADAPTERS
Container adapters are interfaces created by limiting functionality in a pre-existing container and
providing a different set of functionality.
When you declare the container adapters, you have an option of specifying which sequence
containers form the underlying container. These are:
•Stack
•Queue
•Priority Queue.
• A stack is a container providing Last-In First-Out (LIFO) access. Basically, you remove
elements in the reverse order you insert them.. Usually this goes on top of a deque.
• A queue is a container providing First-In First-Out (FIFO) access. You remove elements in
the same order you insert them.. Usually this goes on top of a deque.
• A priority_queue is a container providing sorted-order access to elements. You can insert
elements in any order, and then retrieve the "lowest" of these values at any time and
usually this goes on top of a vector.
#include<iostream>
#include<queue>
Using namespace std;
Int main(){
Queue<int>q;
Q.push(2);
Q.push(3);
QUEUE
PRIORITY QUEUE
#include<iostream>
#include<queue>
Using namespace std;
Int main(){
priority_queue<int>pq;
Pq.push(30);
Pq.push(40)
Pq.push(62);
Pq.push(90);
STACK
#include<iostream>
#include<stack>
Using namespace std;
Int main()
{
stack <int>s;
s.push(2);
s.push(7);
s.push(25);
Find() algorithm
#include <vector>
#include<algorithm>
#include<iostream>
int key;
int arr()={12,3,17,8,34,56,9};
vector<int>v(arr,arr+7);
vector<int>::iterator iter;
cout<<“enter value:”;
cin>>key;
iter=find(v.begin(),v.end(),key);
if(iter!=v.end())
cout<<“Element”<<key<<“found”<<endl;
else
cout<<“Element”<<key<<“not in vector v”<<endl;
Sort and Merge Algorithm
• Sort and merge allows to sort and merge the elements in
container.
#include<list>
int arr1()={6,4,9,1,7};
int arr2()={4,2,1,3,8};
list<int> I1(arr1,arr1+5);
list<int> I2(arr2,arr2+5);
I1.sort();
I2.sort();
I1.merge(I2);
ITERATORS
• An iterator is an object (like a pointer) that points to an element inside the container.
We can use iterators to move through the contents of the container.
• A pointer can point to elements in an array and can iterate through them using the
increment operator (++).
• But, all iterators do not have similar functionality as that of pointers.
Depending upon the functionality of iterators they can be classified into five categories
Input Iterators:
They are the weakest of all the iterators and have very limited functionality. They can
only be used in a single-pass algorithms, i.e., those algorithms which process the
container sequentially, such that no element is accessed more than once.
Just like input iterators, but not for accessing elements, but for being assigned
elements.
Output iterators:
They are higher in the hierarchy than input and output iterators, and contain all the
features present in these two iterators. But, they also can only move in a forward
direction and that too one step at a time.
Forward iterators:
Bidirectional Iterators: They have all the features of forward iterators along with the fact
that they overcome the drawback of forward iterators, as they can move in both the
directions.
Random-Access Iterators: They are the most powerful iterators. They are not limited to
moving sequentially,they can randomly access any element inside the container. They are
the ones whose functionality are same as pointers.
OUTPUT: 6 2 5 7 9 0 8
CONCLUSION
->As a programmer one should be well versed in STL to implement the new
algorithms
->It eliminates the complex looping structures and helps in resolving the extreme real-
world problems for world ease.
->It will help in simplifying the reading of code samples and improve your coding
skills.
oops_final_ppt[1].pptx

More Related Content

Similar to oops_final_ppt[1].pptx

CMSC 202 - Lec20 - Containers and Iterators(2).pptx
CMSC 202 - Lec20 - Containers and Iterators(2).pptxCMSC 202 - Lec20 - Containers and Iterators(2).pptx
CMSC 202 - Lec20 - Containers and Iterators(2).pptx
deathlyfire321
 
Data structures and Algorithm analysis_Lecture 2.pptx
Data structures and Algorithm analysis_Lecture 2.pptxData structures and Algorithm analysis_Lecture 2.pptx
Data structures and Algorithm analysis_Lecture 2.pptx
AhmedEldesoky24
 

Similar to oops_final_ppt[1].pptx (20)

CMSC 202 - Lec20 - Containers and Iterators(2).pptx
CMSC 202 - Lec20 - Containers and Iterators(2).pptxCMSC 202 - Lec20 - Containers and Iterators(2).pptx
CMSC 202 - Lec20 - Containers and Iterators(2).pptx
 
02._Object-Oriented_Programming_Concepts.ppt
02._Object-Oriented_Programming_Concepts.ppt02._Object-Oriented_Programming_Concepts.ppt
02._Object-Oriented_Programming_Concepts.ppt
 
Collections Training
Collections TrainingCollections Training
Collections Training
 
Collections
CollectionsCollections
Collections
 
Python Tutorial Part 1
Python Tutorial Part 1Python Tutorial Part 1
Python Tutorial Part 1
 
stack.pptx
stack.pptxstack.pptx
stack.pptx
 
MODULE-2.pptx
MODULE-2.pptxMODULE-2.pptx
MODULE-2.pptx
 
Data structures and Algorithm analysis_Lecture 2.pptx
Data structures and Algorithm analysis_Lecture 2.pptxData structures and Algorithm analysis_Lecture 2.pptx
Data structures and Algorithm analysis_Lecture 2.pptx
 
Android Database
Android DatabaseAndroid Database
Android Database
 
Lists, Stacks, and Queues: Abstract Data Types
Lists, Stacks, and Queues: Abstract Data TypesLists, Stacks, and Queues: Abstract Data Types
Lists, Stacks, and Queues: Abstract Data Types
 
Queues
Queues Queues
Queues
 
Python first day
Python first dayPython first day
Python first day
 
Python first day
Python first dayPython first day
Python first day
 
Javasession7
Javasession7Javasession7
Javasession7
 
Advanced c#
Advanced c#Advanced c#
Advanced c#
 
Python Data Structures and Algorithms.pptx
Python Data Structures and Algorithms.pptxPython Data Structures and Algorithms.pptx
Python Data Structures and Algorithms.pptx
 
Introduction to Scala
Introduction to ScalaIntroduction to Scala
Introduction to Scala
 
Stack in Sata Structure
Stack in Sata StructureStack in Sata Structure
Stack in Sata Structure
 
Stl Containers
Stl ContainersStl Containers
Stl Containers
 
11000121065_NAITIK CHATTERJEE.ppt
11000121065_NAITIK CHATTERJEE.ppt11000121065_NAITIK CHATTERJEE.ppt
11000121065_NAITIK CHATTERJEE.ppt
 

Recently uploaded

VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
dharasingh5698
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
dollysharma2066
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Kandungan 087776558899
 
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Recently uploaded (20)

VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
 
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdf
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
 
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
 
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
 
Unit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdfUnit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdf
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the start
 
DC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationDC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equation
 

oops_final_ppt[1].pptx

  • 1. Standard Template Libraries Krishna Prasad H 310621104076 Murali Krishnan N 310621104098 R. Rahul 31062110127 Presented by Subject Code: 191CSC302T Subject Name: Object oriented with C++ EASWARI ENGINEERING COLLEGE (Autonomous) Ramapuram, Chennai – 600 089 16th November, 2022 Prithika R 310621104124 Kiruthika K 310621104073
  • 2. CONTENTS • Standard Template Libraries • Containers • Sequence Containers • Associative containers • Container Adapters • Algorithms • Iterators
  • 3. STANDARD TEMPLATE LIBRARIES(STL) • The Standard Template Library (STL) is a set of C++ template classes to provide common programming data structures and functions such as lists, stacks, arrays, etc.
  • 4. CONTAINERS • A container is a holder object that stores a collection of other objects (its elements). They are implemented as class templates, which allows great flexibility in the types supported as elements.
  • 5. SEQUENCE CONTAINERS • Sequence containers implement data structures that can be accessed sequentially. • This includes vectors, list,arrays, dequeue,arrays, forward list. • Vectors are the same as dynamic arrays with the ability to resize itself automatically when an element is inserted or deleted
  • 6. ASSOCIATIVE CONTAINER • It is a variable-sized Container that supports efficient retrieval of elements (values) based on keys. It consists of 4 types SET: A set is an Associative container which contains a sorted set of unique objects of type Key. MULTISET: Multisets are a type of associative containers similar to the set, with the exception that multiple elements can have the same values.
  • 7. • Maps are associative containers that store elements in a mapped fashion. • Each element has a key value and a mapped value. No two mapped values can have the same key values. MAPS: MULTIMAP: • Multimap is similar to a map with the addition that multiple elements can have the same keys. • Keeps all the keys in sorted order.
  • 8. CONTAINER ADAPTERS Container adapters are interfaces created by limiting functionality in a pre-existing container and providing a different set of functionality. When you declare the container adapters, you have an option of specifying which sequence containers form the underlying container. These are: •Stack •Queue •Priority Queue.
  • 9. • A stack is a container providing Last-In First-Out (LIFO) access. Basically, you remove elements in the reverse order you insert them.. Usually this goes on top of a deque. • A queue is a container providing First-In First-Out (FIFO) access. You remove elements in the same order you insert them.. Usually this goes on top of a deque. • A priority_queue is a container providing sorted-order access to elements. You can insert elements in any order, and then retrieve the "lowest" of these values at any time and usually this goes on top of a vector.
  • 10. #include<iostream> #include<queue> Using namespace std; Int main(){ Queue<int>q; Q.push(2); Q.push(3); QUEUE
  • 11. PRIORITY QUEUE #include<iostream> #include<queue> Using namespace std; Int main(){ priority_queue<int>pq; Pq.push(30); Pq.push(40) Pq.push(62); Pq.push(90);
  • 12. STACK #include<iostream> #include<stack> Using namespace std; Int main() { stack <int>s; s.push(2); s.push(7); s.push(25);
  • 13. Find() algorithm #include <vector> #include<algorithm> #include<iostream> int key; int arr()={12,3,17,8,34,56,9}; vector<int>v(arr,arr+7); vector<int>::iterator iter; cout<<“enter value:”; cin>>key; iter=find(v.begin(),v.end(),key); if(iter!=v.end()) cout<<“Element”<<key<<“found”<<endl; else cout<<“Element”<<key<<“not in vector v”<<endl;
  • 14. Sort and Merge Algorithm • Sort and merge allows to sort and merge the elements in container. #include<list> int arr1()={6,4,9,1,7}; int arr2()={4,2,1,3,8}; list<int> I1(arr1,arr1+5); list<int> I2(arr2,arr2+5); I1.sort(); I2.sort(); I1.merge(I2);
  • 15. ITERATORS • An iterator is an object (like a pointer) that points to an element inside the container. We can use iterators to move through the contents of the container. • A pointer can point to elements in an array and can iterate through them using the increment operator (++). • But, all iterators do not have similar functionality as that of pointers.
  • 16. Depending upon the functionality of iterators they can be classified into five categories Input Iterators: They are the weakest of all the iterators and have very limited functionality. They can only be used in a single-pass algorithms, i.e., those algorithms which process the container sequentially, such that no element is accessed more than once. Just like input iterators, but not for accessing elements, but for being assigned elements. Output iterators: They are higher in the hierarchy than input and output iterators, and contain all the features present in these two iterators. But, they also can only move in a forward direction and that too one step at a time. Forward iterators:
  • 17. Bidirectional Iterators: They have all the features of forward iterators along with the fact that they overcome the drawback of forward iterators, as they can move in both the directions. Random-Access Iterators: They are the most powerful iterators. They are not limited to moving sequentially,they can randomly access any element inside the container. They are the ones whose functionality are same as pointers.
  • 18. OUTPUT: 6 2 5 7 9 0 8
  • 19. CONCLUSION ->As a programmer one should be well versed in STL to implement the new algorithms ->It eliminates the complex looping structures and helps in resolving the extreme real- world problems for world ease. ->It will help in simplifying the reading of code samples and improve your coding skills.