SlideShare a Scribd company logo
STANDARD TEMPLATE 
LIBRARY 
BY: 
SUKRITI SINGH 
A0523113081 
BTBM/13/242 
AMITY INSTITUTE OF BIOTECHNOLOGY 
AMITY UNIVERSITY, NOIDA 
Teacher Incharge: 
Mr. Asit Dwivedi
Library 
Classes 
 To help programmers be more productive, 
C++ includes predefined classes in the form 
of packages as part of the installation. 
These are called ‘library classes.’ 
 It offers many packages through its 
libraries. Packages, in turn, provide 
thousands of classes that provides tens of 
thousands of methods for carrying out 
diverse type of tasks.
STANDARD TEMPLATE LIBRARY 
(STL) 
 T he C++ ST L (Standard Template Library) is a powerful set of C++ template 
classes to provide general-purpose templatized classes and functions that 
implement many popular and commonly used algorithms and data structures like 
vectors, lists, queues, and stacks. 
 Standard Template Library (STL) stands for standard template library and is 
basically a library of many useful containers or algorithms. 
 In layman terms , it basically is a class template with functions already created 
making life easier as they need to be merely called to be used. 
 The STL achieves its results through the use of templates. This approach is very 
powerful, delivering compile-time polymorphism that is often more efficient 
than traditional run-time polymorphism. Modern C++ compilers are tuned to 
minimize any abstraction penalty arising from heavy use of the STL.
The Standard Template Library was created as the first library of generic algorithms 
and data structures, with four ideas in mind: generic programming, abstractness 
without loss of efficiency, the Von Neumann computation model, and value semantics. 
The package file in C++ is stored in “namespace std” (namespace groups different 
identifiers in a named scope.), hence before using the library classes we need to call 
this directive as 
using namespace std; 
Function Objects 
Function Objects 
Iterators 
Algorithm Containers
Components 
of STL 
Containers 
Algorithms 
Iterators
Container is a way that stored data is organized in memory, for 
example an array of elements. 
Algorithms in the STL are procedures that are applied to 
containers to process their data, for example search for an 
element in an array, or sort an array. 
Iterators are a generalization of the concept of pointers, they 
point to elements in a container, for example you can 
increment an iterator to point to the next element in an array.
• Algorithm 
Sort, find, search, copy, … 
• Containers 
iterators 
vector, list, map, hash_map, … 
Each container has its own iterator types
Containers 
A container 
is a way to 
store data, 
either 
built-in 
data types 
like int and 
float, or 
class 
objects. 
Generic 
"off-the-shelf“ 
class 
templates 
for storing 
collections 
of data. 
Containers 
are used to 
manage 
collections 
of objects 
of a certain 
kind. 
There are 
several 
different 
types of 
containers 
like deque, 
list, vector, 
map etc.
Kinds of 
Containers 
Sequence 
• Store elements in linear sequence 
• Vectors, Linked Lists, and derivatives 
Adaptors 
• Used to automatically arrange stored 
data in a specific order. Uses trees 
• Queue, Priority_Queue, Stack 
Associative 
• Special purpose containers created 
from normal containers 
• Hash, Map, Set, Multimap, Multiset
Sequence 
Containers 
Special purpose containers created from normal 
containers.These containers store and retrieve data in a 
sequential fashion. 
A sequence container stores a set of elements in sequence, in 
other words each element (except for the first and last one) is 
preceded by one specific element and followed by another. 
In an ordinary C++ array the size is fixed and can not change 
during run-time, it is also tedious to insert or delete elements. 
Advantage: quick random access
Stores elements by 
position 
Each item in the list 
has both a value and a 
memory address 
(pointer) that 
identifies the next 
item in the sequence 
To access a specific 
data value in the list, 
one must start at the 
first position (front) 
and follow the 
pointers from element 
to element until data 
item is located. 
Basic Steps 
to Work in 
Sequence 
Containers
vector 
– dynamic array 
(hold sequences in difference ways) 
• Offers random but ‘direct’ access. 
• Back insertion 
• Should be your default choice, but choose wisely 
• Compatible with C : &v[0] points to the first element 
• Treated as an array with the capability of growing or shrinking 
dynamically. The elements can be accessed in two ways: 
i. using the overloaded operator ( ) 
ii. using the method at 
• The first one is easier and faster to use, but it is not range checked. 
• On the other hand, the method does range checking and throws 
out_of_range exception if needed.
deque 
– double-ended queue (usually array of arrays) 
o Offers random access 
o Back and Front insertion 
o Slower than vectors 
o No C - compatibility 
o This is basically a double-ended queue. 
o If we want to grow/shrink in a deque, we can do it at both the ends. 
o It provides the same accessing efficiency as the vector but the allocation efficiency 
comparable with a list.
list 
– 'traditional' doubly linked list 
 Don't expect random access 
 You can insert anywhere though, Arrays are optimised for random access 
but are inefficient when it comes to inserting and deleting elements in the 
middle; so are the vector and deque. 
 For operations requiring intensive insertions and deletions, use a list, which 
is very efficient for these operations (and is internally implemented as a 
double-linked list). 
 With a list, you cannot have random access to the data and so the operator 
is not overloaded.
Associative 
Containers 
• As the name suggest ‘Associate’ is linking it to 
different nodes. 
• Used to automatically arrange stored data in a 
specific order. Uses trees. 
• Tress provide and facilitates faster searching. 
• An associative container is non-sequential but uses a 
key to access elements. 
• The keys, typically a number or a string, are used by 
the container to arrange the stored elements in a 
specific order 
• for example in a dictionary the entries are ordered 
alphabetically.
Comparison of Trees, Lists, Arrays 
Trees : They are non-linear data structures, where a unique path exists to traverse(moving ahead or 
accessing) a particular node. Binary trees can utmost have 2 nodes, read either as Pre,In or Post. 
Node: It is a self referential data structure, which works on sending reference of its location to 
link of sets or maps. 
Link list: It is a serial collection of nodes. While this is a linear data structure. 
Array is a serial memory allocation while lists having serial nodes have a reference to the memory 
hence allocated randomly and linked to each other through references. 
Non-linear data 
structure engages 
memory in non 
sequential order. 
Linear data structures 
engages memory 
linearly or in a 
sequential order. 
Hence, we can 
conclude that
Maps: 
• Stores unique key/value pairs 
• key is associated with only one value (One-to-One 
Mapping). 
• Rapid key-based lookup. 
Sets: 
• Store the elements along with a unique key. 
• The values are irrelevant and we keep track of the 
keys only 
• Rapid lookup 
Common Points: 
• These two are interchangeable. 
• No duplicates 
• They provide an important functionality, 
Maps 
and 
Sets
3 
1 
0 2 5 
8 
7 
4 6
Multisets and Multimaps: 
These are extended versions of a map and set espectively. 
Multisets: 
• Stores non-unique sets 
• duplicates are allowed, Rapid lookup. 
Multimaps: 
• Stores non-unique key/value pairs 
• one key may be associated with more than one value (One-to-Many Mapping) 
• Duplicates are allowed 
• Rapid key based lookup
Adapter 
Containers 
Also known as Derived 
Containers. 
Provide different ways to 
access sequential & 
associative containers. 
They are implemented 
using the containers seen 
before 
They do not provide 
actual data structure 
Container adapters do 
not support iterators 
The functions push and 
pop are common to all 
container adapters 
component that adapts 
(modifies) an existing 
interface of a component 
to expose a different one 
suitable for some 
purpose. 
These containers restrict 
how elements enter and 
leave a sequence
Stack 
LIFO 
Last-in-first-out 
data 
structure 
They are 
implemented 
with vector, 
list, and deque 
(by default) 
Allows access 
at only one 
end of the 
sequence (top) 
Adds objects 
to container by 
pushing the 
object onto 
the stack 
Removes 
objects from 
container by 
popping the 
stack
Queue 
FIFO 
First in First 
Out Data 
Structure. 
Implemented 
with list and 
deque (by 
default). 
Allows access 
only at the 
front and 
rear of the 
sequence. 
Items enter 
at the rear 
and exit 
from the 
front. 
Example: 
waiting line 
at a grocery 
store.
Priority 
Queue 
• Insertions are done in a sorted order 
• Deletions from front similar to a queue 
• They are implemented with vector (by default) or deque 
• The elements with the highest priority are removed first 
• Operations are similar to those of a stack or queue 
• Elements can enter the priority queue in any order 
• Once in the container, a delete operation removes the largest (or 
smallest) value 
• Example: a filtering system that takes in elements and then releases 
them in priority order 
18 13 
3 15
In mathematics and Algorithm 
computer science, an 
algorithm is a step-by-step 
procedure. 
It is a specific set of 
instructions for carrying 
out a procedure or solving 
a problem 
Usually with the 
requirement that the 
procedure terminate at 
some point. 
Specific algorithms 
sometimes also go by the 
name method, procedure, 
or technique.
Algorithms typically take iterators as arguments 
Container provides a way to access its elements using 
iterators. 
Algorithms act on containers. 
Provide the means by which you will perform initialization, sorting 
, searching , and transforming of the contents of containers.
Iterators 
 Iterators are generalised pointers and act as the glue 
between containers and algorithms. 
 STL algorithms are written in terms of iterator 
parameters, and STL containers provide iterators that can 
be plugged into algorithms. 
 Generally, iterators point to a location within a container. 
 Iterators have a pointer-like syntax (in many cases, 
iterators are indeed implemented as pointers internally).
Iterators are used to step 
throug h the elements of 
collections of objects. 
These collections 
may be containers or 
subsets of containers. 
Iterators are pointer-like entities 
that are used to access individual 
elements in a container. 
Often they are used to move sequentially 
from element to element, a process 
called iterating through a container. 
One can have multiple iterators 
pointing to different or identical 
elements in the container
Container Type of iterator supported 
Sequence containers 
vector random access 
deque random access 
list bidirectional 
Associative containers 
set bidirectional 
multiset bidirectional 
map bidirectional 
multimap bidirectional 
Container adapters 
stack no iterators supported 
queue no iterators supported 
priority_queue 
no iterators supported
Compiling STL 
Container 
Algorithm 
Iterator 
Container 
Iterator 
Algorithm 
Objects 
Iterator 
Iterator 
Algorithm
Thank 
You!!!!

More Related Content

What's hot

Java threads
Java threadsJava threads
Java threads
Prabhakaran V M
 
Java Collections
Java CollectionsJava Collections
Java Collectionsparag
 
Data structure and its types
Data structure and its typesData structure and its types
Data structure and its typesNavtar Sidhu Brar
 
Abstract Data Types
Abstract Data TypesAbstract Data Types
Abstract Data Types
Reggie Niccolo Santos
 
String Builder & String Buffer (Java Programming)
String Builder & String Buffer (Java Programming)String Builder & String Buffer (Java Programming)
String Builder & String Buffer (Java Programming)
Anwar Hasan Shuvo
 
Java I/o streams
Java I/o streamsJava I/o streams
Java I/o streams
Hamid Ghorbani
 
Collections - Array List
Collections - Array List Collections - Array List
Collections - Array List
Hitesh-Java
 
collection framework in java
collection framework in javacollection framework in java
collection framework in java
MANOJ KUMAR
 
Java Collections Tutorials
Java Collections TutorialsJava Collections Tutorials
Java Collections Tutorials
Prof. Erwin Globio
 
Priority queue in DSA
Priority queue in DSAPriority queue in DSA
Priority queue in DSA
junnubabu
 
Collections Api - Java
Collections Api - JavaCollections Api - Java
Collections Api - Java
Drishti Bhalla
 
Files in java
Files in javaFiles in java
Stl (standard template library)
Stl (standard template library)Stl (standard template library)
Stl (standard template library)Hemant Jain
 
Abstract Data Types
Abstract Data TypesAbstract Data Types
Abstract Data Types
karthikeyanC40
 
Collections in Java Notes
Collections in Java NotesCollections in Java Notes
Collections in Java Notes
Shalabh Chaudhary
 
Collections framework in java
Collections framework in javaCollections framework in java
Collections framework in java
yugandhar vadlamudi
 
Java Collections | Collections Framework in Java | Java Tutorial For Beginner...
Java Collections | Collections Framework in Java | Java Tutorial For Beginner...Java Collections | Collections Framework in Java | Java Tutorial For Beginner...
Java Collections | Collections Framework in Java | Java Tutorial For Beginner...
Edureka!
 
Queue data structure
Queue data structureQueue data structure
Queue data structure
anooppjoseph
 
Java Collection framework
Java Collection frameworkJava Collection framework
Java Collection framework
ankitgarg_er
 

What's hot (20)

Java threads
Java threadsJava threads
Java threads
 
Java Collections
Java CollectionsJava Collections
Java Collections
 
Data structure and its types
Data structure and its typesData structure and its types
Data structure and its types
 
Abstract Data Types
Abstract Data TypesAbstract Data Types
Abstract Data Types
 
String Builder & String Buffer (Java Programming)
String Builder & String Buffer (Java Programming)String Builder & String Buffer (Java Programming)
String Builder & String Buffer (Java Programming)
 
Java I/o streams
Java I/o streamsJava I/o streams
Java I/o streams
 
Collections - Array List
Collections - Array List Collections - Array List
Collections - Array List
 
collection framework in java
collection framework in javacollection framework in java
collection framework in java
 
Java Collections Tutorials
Java Collections TutorialsJava Collections Tutorials
Java Collections Tutorials
 
Priority queue in DSA
Priority queue in DSAPriority queue in DSA
Priority queue in DSA
 
Collections Api - Java
Collections Api - JavaCollections Api - Java
Collections Api - Java
 
Files in java
Files in javaFiles in java
Files in java
 
Stl (standard template library)
Stl (standard template library)Stl (standard template library)
Stl (standard template library)
 
Abstract Data Types
Abstract Data TypesAbstract Data Types
Abstract Data Types
 
Packages and interfaces
Packages and interfacesPackages and interfaces
Packages and interfaces
 
Collections in Java Notes
Collections in Java NotesCollections in Java Notes
Collections in Java Notes
 
Collections framework in java
Collections framework in javaCollections framework in java
Collections framework in java
 
Java Collections | Collections Framework in Java | Java Tutorial For Beginner...
Java Collections | Collections Framework in Java | Java Tutorial For Beginner...Java Collections | Collections Framework in Java | Java Tutorial For Beginner...
Java Collections | Collections Framework in Java | Java Tutorial For Beginner...
 
Queue data structure
Queue data structureQueue data structure
Queue data structure
 
Java Collection framework
Java Collection frameworkJava Collection framework
Java Collection framework
 

Viewers also liked

How to choose best containers in STL (C++)
How to choose best containers in STL (C++)How to choose best containers in STL (C++)
How to choose best containers in STL (C++)
Sangharsh agarwal
 
Algoritmi e Calcolo Parallelo 2012/2013 - Code di Priorita'
Algoritmi e Calcolo Parallelo 2012/2013 - Code di Priorita'Algoritmi e Calcolo Parallelo 2012/2013 - Code di Priorita'
Algoritmi e Calcolo Parallelo 2012/2013 - Code di Priorita'
Pier Luca Lanzi
 
C++ Standard Template Library
C++ Standard Template LibraryC++ Standard Template Library
C++ Standard Template LibraryDuda Dornelles
 
C++ STL 概觀
C++ STL 概觀C++ STL 概觀
C++ STL 概觀
PingLun Liao
 
Standard Template Library
Standard Template LibraryStandard Template Library
Standard Template Library
Kumar Gaurav
 
An Introduction to Part of C++ STL
An Introduction to Part of C++ STLAn Introduction to Part of C++ STL
An Introduction to Part of C++ STL
乐群 陈
 
Lecture11 standard template-library
Lecture11 standard template-libraryLecture11 standard template-library
Lecture11 standard template-libraryHariz Mustafa
 
Stl Containers
Stl ContainersStl Containers
Stl Containers
ppd1961
 
C++ Standard Template Library
C++ Standard Template LibraryC++ Standard Template Library
C++ Standard Template Library
Ilio Catallo
 

Viewers also liked (9)

How to choose best containers in STL (C++)
How to choose best containers in STL (C++)How to choose best containers in STL (C++)
How to choose best containers in STL (C++)
 
Algoritmi e Calcolo Parallelo 2012/2013 - Code di Priorita'
Algoritmi e Calcolo Parallelo 2012/2013 - Code di Priorita'Algoritmi e Calcolo Parallelo 2012/2013 - Code di Priorita'
Algoritmi e Calcolo Parallelo 2012/2013 - Code di Priorita'
 
C++ Standard Template Library
C++ Standard Template LibraryC++ Standard Template Library
C++ Standard Template Library
 
C++ STL 概觀
C++ STL 概觀C++ STL 概觀
C++ STL 概觀
 
Standard Template Library
Standard Template LibraryStandard Template Library
Standard Template Library
 
An Introduction to Part of C++ STL
An Introduction to Part of C++ STLAn Introduction to Part of C++ STL
An Introduction to Part of C++ STL
 
Lecture11 standard template-library
Lecture11 standard template-libraryLecture11 standard template-library
Lecture11 standard template-library
 
Stl Containers
Stl ContainersStl Containers
Stl Containers
 
C++ Standard Template Library
C++ Standard Template LibraryC++ Standard Template Library
C++ Standard Template Library
 

Similar to Standard template library

DS Module1 (1).pptx
DS Module1 (1).pptxDS Module1 (1).pptx
DS Module1 (1).pptx
AnuJoseph95
 
Python Data Structures and Algorithms.pptx
Python Data Structures and Algorithms.pptxPython Data Structures and Algorithms.pptx
Python Data Structures and Algorithms.pptx
ShreyasLawand
 
Standard template library
Standard template libraryStandard template library
Standard template library
ThamizhselviKrishnam
 
data science
data sciencedata science
data science
KamleshParihar12
 
Unit 2 linear data structures
Unit 2   linear data structuresUnit 2   linear data structures
Unit 2 linear data structures
Senthil Murugan
 
Data Structure & Algorithm.pptx
Data Structure & Algorithm.pptxData Structure & Algorithm.pptx
Data Structure & Algorithm.pptx
Mumtaz
 
linked_list.pdf [for undergraduate students
linked_list.pdf [for undergraduate studentslinked_list.pdf [for undergraduate students
linked_list.pdf [for undergraduate students
SazzadulIslam42
 
oops_final_ppt[1].pptx
oops_final_ppt[1].pptxoops_final_ppt[1].pptx
oops_final_ppt[1].pptx
12KrishnaPrasadH
 
lecture 02.2.ppt
lecture 02.2.pptlecture 02.2.ppt
lecture 02.2.ppt
NathanielAdika
 
Data_structure.pptx
Data_structure.pptxData_structure.pptx
Data_structure.pptx
priya415376
 
Collections Training
Collections TrainingCollections Training
Collections Training
Ramindu Deshapriya
 
DS Module 1.pptx
DS Module 1.pptxDS Module 1.pptx
DS Module 1.pptx
SaralaT3
 
DS Module 1.pptx
DS Module 1.pptxDS Module 1.pptx
DS Module 1.pptx
sarala9
 
The Standard Template Library
The Standard Template LibraryThe Standard Template Library
The Standard Template Library
Munazza-Mah-Jabeen
 
Data structures - unit 1
Data structures - unit 1Data structures - unit 1
Data structures - unit 1
SaranyaP45
 
stack.pptx
stack.pptxstack.pptx
stack.pptx
mayankKatiyar17
 
Data structures in c#
Data structures in c#Data structures in c#
Data structures in c#
SivaSankar Gorantla
 
TSAT Presentation1.pptx
TSAT Presentation1.pptxTSAT Presentation1.pptx
TSAT Presentation1.pptx
Rajitha Reddy Alugati
 
358 33 powerpoint-slides_4-introduction-data-structures_chapter-4
358 33 powerpoint-slides_4-introduction-data-structures_chapter-4358 33 powerpoint-slides_4-introduction-data-structures_chapter-4
358 33 powerpoint-slides_4-introduction-data-structures_chapter-4
sumitbardhan
 

Similar to Standard template library (20)

DS Module1 (1).pptx
DS Module1 (1).pptxDS Module1 (1).pptx
DS Module1 (1).pptx
 
Python Data Structures and Algorithms.pptx
Python Data Structures and Algorithms.pptxPython Data Structures and Algorithms.pptx
Python Data Structures and Algorithms.pptx
 
Standard template library
Standard template libraryStandard template library
Standard template library
 
data science
data sciencedata science
data science
 
Unit 2 linear data structures
Unit 2   linear data structuresUnit 2   linear data structures
Unit 2 linear data structures
 
Data Structure & Algorithm.pptx
Data Structure & Algorithm.pptxData Structure & Algorithm.pptx
Data Structure & Algorithm.pptx
 
linked_list.pdf [for undergraduate students
linked_list.pdf [for undergraduate studentslinked_list.pdf [for undergraduate students
linked_list.pdf [for undergraduate students
 
oops_final_ppt[1].pptx
oops_final_ppt[1].pptxoops_final_ppt[1].pptx
oops_final_ppt[1].pptx
 
lecture 02.2.ppt
lecture 02.2.pptlecture 02.2.ppt
lecture 02.2.ppt
 
Data_structure.pptx
Data_structure.pptxData_structure.pptx
Data_structure.pptx
 
Collections Training
Collections TrainingCollections Training
Collections Training
 
DS Module 1.pptx
DS Module 1.pptxDS Module 1.pptx
DS Module 1.pptx
 
DS Module 1.pptx
DS Module 1.pptxDS Module 1.pptx
DS Module 1.pptx
 
The Standard Template Library
The Standard Template LibraryThe Standard Template Library
The Standard Template Library
 
Data structures - unit 1
Data structures - unit 1Data structures - unit 1
Data structures - unit 1
 
stack.pptx
stack.pptxstack.pptx
stack.pptx
 
Javasession7
Javasession7Javasession7
Javasession7
 
Data structures in c#
Data structures in c#Data structures in c#
Data structures in c#
 
TSAT Presentation1.pptx
TSAT Presentation1.pptxTSAT Presentation1.pptx
TSAT Presentation1.pptx
 
358 33 powerpoint-slides_4-introduction-data-structures_chapter-4
358 33 powerpoint-slides_4-introduction-data-structures_chapter-4358 33 powerpoint-slides_4-introduction-data-structures_chapter-4
358 33 powerpoint-slides_4-introduction-data-structures_chapter-4
 

More from Sukriti Singh

The duchess and the jeweler
The duchess and the jewelerThe duchess and the jeweler
The duchess and the jeweler
Sukriti Singh
 
Demonetisation
DemonetisationDemonetisation
Demonetisation
Sukriti Singh
 
Reading and listening comprehension
Reading and listening comprehensionReading and listening comprehension
Reading and listening comprehension
Sukriti Singh
 
Patents and case study
Patents and case study Patents and case study
Patents and case study
Sukriti Singh
 
Immobilisation cell culture
Immobilisation cell cultureImmobilisation cell culture
Immobilisation cell culture
Sukriti Singh
 
Hydrogels assignment 2
Hydrogels assignment 2Hydrogels assignment 2
Hydrogels assignment 2
Sukriti Singh
 
Grapevine communication
Grapevine communicationGrapevine communication
Grapevine communication
Sukriti Singh
 
Good governance
Good governanceGood governance
Good governance
Sukriti Singh
 
Gas chromatography
Gas chromatographyGas chromatography
Gas chromatography
Sukriti Singh
 
Epidemiology
EpidemiologyEpidemiology
Epidemiology
Sukriti Singh
 
Effect of cosmetics pptx
Effect of cosmetics pptxEffect of cosmetics pptx
Effect of cosmetics pptx
Sukriti Singh
 
Design and development of data collection
Design and development of data collectionDesign and development of data collection
Design and development of data collection
Sukriti Singh
 
Cancer Chemoprevention and Molecular Targeting Drug Delivery for Cancer
Cancer Chemoprevention and Molecular Targeting Drug Delivery for CancerCancer Chemoprevention and Molecular Targeting Drug Delivery for Cancer
Cancer Chemoprevention and Molecular Targeting Drug Delivery for Cancer
Sukriti Singh
 
Bioterrorism and drug prepardness
Bioterrorism and drug prepardnessBioterrorism and drug prepardness
Bioterrorism and drug prepardness
Sukriti Singh
 
Biofuels
BiofuelsBiofuels
Biofuels
Sukriti Singh
 
Artistic freedom – should there be limits
Artistic freedom – should there be limitsArtistic freedom – should there be limits
Artistic freedom – should there be limits
Sukriti Singh
 
The Proof of the Pudding
The Proof of the PuddingThe Proof of the Pudding
The Proof of the Pudding
Sukriti Singh
 
Web based writing - English Asignment
Web based writing - English AsignmentWeb based writing - English Asignment
Web based writing - English Asignment
Sukriti Singh
 
Good governance
Good governanceGood governance
Good governance
Sukriti Singh
 
Punctuations
PunctuationsPunctuations
Punctuations
Sukriti Singh
 

More from Sukriti Singh (20)

The duchess and the jeweler
The duchess and the jewelerThe duchess and the jeweler
The duchess and the jeweler
 
Demonetisation
DemonetisationDemonetisation
Demonetisation
 
Reading and listening comprehension
Reading and listening comprehensionReading and listening comprehension
Reading and listening comprehension
 
Patents and case study
Patents and case study Patents and case study
Patents and case study
 
Immobilisation cell culture
Immobilisation cell cultureImmobilisation cell culture
Immobilisation cell culture
 
Hydrogels assignment 2
Hydrogels assignment 2Hydrogels assignment 2
Hydrogels assignment 2
 
Grapevine communication
Grapevine communicationGrapevine communication
Grapevine communication
 
Good governance
Good governanceGood governance
Good governance
 
Gas chromatography
Gas chromatographyGas chromatography
Gas chromatography
 
Epidemiology
EpidemiologyEpidemiology
Epidemiology
 
Effect of cosmetics pptx
Effect of cosmetics pptxEffect of cosmetics pptx
Effect of cosmetics pptx
 
Design and development of data collection
Design and development of data collectionDesign and development of data collection
Design and development of data collection
 
Cancer Chemoprevention and Molecular Targeting Drug Delivery for Cancer
Cancer Chemoprevention and Molecular Targeting Drug Delivery for CancerCancer Chemoprevention and Molecular Targeting Drug Delivery for Cancer
Cancer Chemoprevention and Molecular Targeting Drug Delivery for Cancer
 
Bioterrorism and drug prepardness
Bioterrorism and drug prepardnessBioterrorism and drug prepardness
Bioterrorism and drug prepardness
 
Biofuels
BiofuelsBiofuels
Biofuels
 
Artistic freedom – should there be limits
Artistic freedom – should there be limitsArtistic freedom – should there be limits
Artistic freedom – should there be limits
 
The Proof of the Pudding
The Proof of the PuddingThe Proof of the Pudding
The Proof of the Pudding
 
Web based writing - English Asignment
Web based writing - English AsignmentWeb based writing - English Asignment
Web based writing - English Asignment
 
Good governance
Good governanceGood governance
Good governance
 
Punctuations
PunctuationsPunctuations
Punctuations
 

Recently uploaded

FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 

Recently uploaded (20)

FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 

Standard template library

  • 1. STANDARD TEMPLATE LIBRARY BY: SUKRITI SINGH A0523113081 BTBM/13/242 AMITY INSTITUTE OF BIOTECHNOLOGY AMITY UNIVERSITY, NOIDA Teacher Incharge: Mr. Asit Dwivedi
  • 2. Library Classes  To help programmers be more productive, C++ includes predefined classes in the form of packages as part of the installation. These are called ‘library classes.’  It offers many packages through its libraries. Packages, in turn, provide thousands of classes that provides tens of thousands of methods for carrying out diverse type of tasks.
  • 3. STANDARD TEMPLATE LIBRARY (STL)  T he C++ ST L (Standard Template Library) is a powerful set of C++ template classes to provide general-purpose templatized classes and functions that implement many popular and commonly used algorithms and data structures like vectors, lists, queues, and stacks.  Standard Template Library (STL) stands for standard template library and is basically a library of many useful containers or algorithms.  In layman terms , it basically is a class template with functions already created making life easier as they need to be merely called to be used.  The STL achieves its results through the use of templates. This approach is very powerful, delivering compile-time polymorphism that is often more efficient than traditional run-time polymorphism. Modern C++ compilers are tuned to minimize any abstraction penalty arising from heavy use of the STL.
  • 4. The Standard Template Library was created as the first library of generic algorithms and data structures, with four ideas in mind: generic programming, abstractness without loss of efficiency, the Von Neumann computation model, and value semantics. The package file in C++ is stored in “namespace std” (namespace groups different identifiers in a named scope.), hence before using the library classes we need to call this directive as using namespace std; Function Objects Function Objects Iterators Algorithm Containers
  • 5. Components of STL Containers Algorithms Iterators
  • 6. Container is a way that stored data is organized in memory, for example an array of elements. Algorithms in the STL are procedures that are applied to containers to process their data, for example search for an element in an array, or sort an array. Iterators are a generalization of the concept of pointers, they point to elements in a container, for example you can increment an iterator to point to the next element in an array.
  • 7. • Algorithm Sort, find, search, copy, … • Containers iterators vector, list, map, hash_map, … Each container has its own iterator types
  • 8. Containers A container is a way to store data, either built-in data types like int and float, or class objects. Generic "off-the-shelf“ class templates for storing collections of data. Containers are used to manage collections of objects of a certain kind. There are several different types of containers like deque, list, vector, map etc.
  • 9. Kinds of Containers Sequence • Store elements in linear sequence • Vectors, Linked Lists, and derivatives Adaptors • Used to automatically arrange stored data in a specific order. Uses trees • Queue, Priority_Queue, Stack Associative • Special purpose containers created from normal containers • Hash, Map, Set, Multimap, Multiset
  • 10. Sequence Containers Special purpose containers created from normal containers.These containers store and retrieve data in a sequential fashion. A sequence container stores a set of elements in sequence, in other words each element (except for the first and last one) is preceded by one specific element and followed by another. In an ordinary C++ array the size is fixed and can not change during run-time, it is also tedious to insert or delete elements. Advantage: quick random access
  • 11.
  • 12. Stores elements by position Each item in the list has both a value and a memory address (pointer) that identifies the next item in the sequence To access a specific data value in the list, one must start at the first position (front) and follow the pointers from element to element until data item is located. Basic Steps to Work in Sequence Containers
  • 13. vector – dynamic array (hold sequences in difference ways) • Offers random but ‘direct’ access. • Back insertion • Should be your default choice, but choose wisely • Compatible with C : &v[0] points to the first element • Treated as an array with the capability of growing or shrinking dynamically. The elements can be accessed in two ways: i. using the overloaded operator ( ) ii. using the method at • The first one is easier and faster to use, but it is not range checked. • On the other hand, the method does range checking and throws out_of_range exception if needed.
  • 14. deque – double-ended queue (usually array of arrays) o Offers random access o Back and Front insertion o Slower than vectors o No C - compatibility o This is basically a double-ended queue. o If we want to grow/shrink in a deque, we can do it at both the ends. o It provides the same accessing efficiency as the vector but the allocation efficiency comparable with a list.
  • 15. list – 'traditional' doubly linked list  Don't expect random access  You can insert anywhere though, Arrays are optimised for random access but are inefficient when it comes to inserting and deleting elements in the middle; so are the vector and deque.  For operations requiring intensive insertions and deletions, use a list, which is very efficient for these operations (and is internally implemented as a double-linked list).  With a list, you cannot have random access to the data and so the operator is not overloaded.
  • 16. Associative Containers • As the name suggest ‘Associate’ is linking it to different nodes. • Used to automatically arrange stored data in a specific order. Uses trees. • Tress provide and facilitates faster searching. • An associative container is non-sequential but uses a key to access elements. • The keys, typically a number or a string, are used by the container to arrange the stored elements in a specific order • for example in a dictionary the entries are ordered alphabetically.
  • 17. Comparison of Trees, Lists, Arrays Trees : They are non-linear data structures, where a unique path exists to traverse(moving ahead or accessing) a particular node. Binary trees can utmost have 2 nodes, read either as Pre,In or Post. Node: It is a self referential data structure, which works on sending reference of its location to link of sets or maps. Link list: It is a serial collection of nodes. While this is a linear data structure. Array is a serial memory allocation while lists having serial nodes have a reference to the memory hence allocated randomly and linked to each other through references. Non-linear data structure engages memory in non sequential order. Linear data structures engages memory linearly or in a sequential order. Hence, we can conclude that
  • 18.
  • 19. Maps: • Stores unique key/value pairs • key is associated with only one value (One-to-One Mapping). • Rapid key-based lookup. Sets: • Store the elements along with a unique key. • The values are irrelevant and we keep track of the keys only • Rapid lookup Common Points: • These two are interchangeable. • No duplicates • They provide an important functionality, Maps and Sets
  • 20. 3 1 0 2 5 8 7 4 6
  • 21. Multisets and Multimaps: These are extended versions of a map and set espectively. Multisets: • Stores non-unique sets • duplicates are allowed, Rapid lookup. Multimaps: • Stores non-unique key/value pairs • one key may be associated with more than one value (One-to-Many Mapping) • Duplicates are allowed • Rapid key based lookup
  • 22. Adapter Containers Also known as Derived Containers. Provide different ways to access sequential & associative containers. They are implemented using the containers seen before They do not provide actual data structure Container adapters do not support iterators The functions push and pop are common to all container adapters component that adapts (modifies) an existing interface of a component to expose a different one suitable for some purpose. These containers restrict how elements enter and leave a sequence
  • 23.
  • 24. Stack LIFO Last-in-first-out data structure They are implemented with vector, list, and deque (by default) Allows access at only one end of the sequence (top) Adds objects to container by pushing the object onto the stack Removes objects from container by popping the stack
  • 25. Queue FIFO First in First Out Data Structure. Implemented with list and deque (by default). Allows access only at the front and rear of the sequence. Items enter at the rear and exit from the front. Example: waiting line at a grocery store.
  • 26. Priority Queue • Insertions are done in a sorted order • Deletions from front similar to a queue • They are implemented with vector (by default) or deque • The elements with the highest priority are removed first • Operations are similar to those of a stack or queue • Elements can enter the priority queue in any order • Once in the container, a delete operation removes the largest (or smallest) value • Example: a filtering system that takes in elements and then releases them in priority order 18 13 3 15
  • 27. In mathematics and Algorithm computer science, an algorithm is a step-by-step procedure. It is a specific set of instructions for carrying out a procedure or solving a problem Usually with the requirement that the procedure terminate at some point. Specific algorithms sometimes also go by the name method, procedure, or technique.
  • 28. Algorithms typically take iterators as arguments Container provides a way to access its elements using iterators. Algorithms act on containers. Provide the means by which you will perform initialization, sorting , searching , and transforming of the contents of containers.
  • 29. Iterators  Iterators are generalised pointers and act as the glue between containers and algorithms.  STL algorithms are written in terms of iterator parameters, and STL containers provide iterators that can be plugged into algorithms.  Generally, iterators point to a location within a container.  Iterators have a pointer-like syntax (in many cases, iterators are indeed implemented as pointers internally).
  • 30. Iterators are used to step throug h the elements of collections of objects. These collections may be containers or subsets of containers. Iterators are pointer-like entities that are used to access individual elements in a container. Often they are used to move sequentially from element to element, a process called iterating through a container. One can have multiple iterators pointing to different or identical elements in the container
  • 31. Container Type of iterator supported Sequence containers vector random access deque random access list bidirectional Associative containers set bidirectional multiset bidirectional map bidirectional multimap bidirectional Container adapters stack no iterators supported queue no iterators supported priority_queue no iterators supported
  • 32. Compiling STL Container Algorithm Iterator Container Iterator Algorithm Objects Iterator Iterator Algorithm

Editor's Notes

  1. Generic programming: is a style of computer programming in which algorithms are written in terms of to-be-specified-later types that are then instantiated when needed for specific types provided as parameters.