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
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.
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.
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.