Transcript ITERATORS

PRESENTED BY:
17040603
RAJKRISHNADEEPAK.VUYYURU
17035523
SWAMYCHANDAN.DONDAPATI
17028670
VINESHKUMARREDDY.LANKA
17040235
RAJSEKHARTIRUMALA KANDURI
ALAN GOUDE
S
T
A
N
D
A
R
D
T
E
M
P
L
A
T
E
L
I
B
R
A
R
Y
 A generic library to manage collections of data with efficient
algorithms.
 The STL is a complex piece of software engineering that uses
some of C++'s most sophisticated features
 The Standard Template Library is mainly composed of generic
container class templates and a set of many efficient template
algorithms designed to work with, and manipulate, the containers.
 The classes declared and defined in STL use templates to their
fullest capacity, enabling truly generic programming for C++
programmers.
 The template syntax that describes the STL can seem quite
intimidating.
 Although it looks more complicated than it is actually , while
there is nothing in STL that is any more difficult than the other
features of C++.
 STL defines various routines that access them. Because the STL is
constructed from template classes, the algorithms and data structures can
be applied to nearly any type of data.

STRUCTURAL FLOW OF STL COMPONENTS
ITERATOR
ITERATOR
ALGORITHM
ITERATOR
CONTAINER
 Container classes are c++ classes that act as container for other objects,
suchasanarrayor a linked list.
 A common type of a container is it's an "Array", a built in feature of c++.containers
are more powerful, flexible than arrays.
 Containers have its own memory as well as its track record of objects they hold.
Container classes provide structured, dynamic storage in reusable modules that you
can easily plug in to any program where they might be needed
 Containers are called as building blocks as they are used to create object -oriented
programs and which make the internals of a program to construct more easily.
 CONTAINERS
 Queue

Queue is also known as “ First IN First OUT ".

Queue is a data structure that represents a line.

The elements that are placed in the queue are the longest one in the queue that
can be accessed first.

The data items enter the queue at the Rear and leaves from the Front

The operation used to enter the data item into the queue is called Enqueue and
operation used to remove the data item is called Dequeue.
 syntax

Template <class T, Class container = deque <T> > class queue
T--> type of data being stored
 MEMBER FUNCTIONS OF QUEUE


Map:
The map class provides look up using a rapid key based look up.

Duplicates are not allowed.



The elements in the map are in the form of pairs containing keys and values.

To insert an element into map requires a pair object that has the key and a value.

The map cannot store more than one value against each key because each key can
only appear once, if you try and add a second instance of the same key, then that
will supersede the existing one.
Insertions and deletions are possible at any where in the map.
Some Map Access Functions:
Map Access functions
Purpose
 Some Map Access Functions Purpose
begin()
Returns iterator
pointing to first element

------------------------------end()
Returns iterator
pointing
_after_
last element

begin()
Returns
iterator
pointing
to first
swap( element
,)
Swap two elements
insert(
)
Insert a new
elementiterator pointing _after_ last
 , end()
Returns
size() element
Number of elements in map

swap( , )
Swap two
elements
max_size()
Maximum possible
number
of elements in map

insert( , )
Insert
a new element
empty()
True if map
is empty
[]
"Subscript
search" access
operator in map
size()
Number
of elements

max_size()
Maximum possible number of
elements in map

empty()
True if map is empty

[]
"Subscript search" access operator

ITERATORS

An Iterator points one element then it can be increased to the next element.

ITERATORS are generic programmes.because they are the interface between
containers and algorithms.

Iterators take algorithm as argument, So the container must act to access their
element to iterators.There is a possibilty of algorithms that operates different kinds
of container.

Iterators are used to iterate a range of objects. if related to iterators and several
pre-defined iterators.

Syntax :
std::class_name<template_parameters>:: iterator name
 TYPES
OF ITERATORS
 Algorithms

An algorithm is nothing but single sequential flow of control

Many common algorithms are implemented for queues and maps.

Sorting, searching, inserting, deleting, shuffling, permuting, rotating, reversing,
moving, copying, counting, minimum and maximum are some
types of algorithms.
 Types of algorithms
Mutating Sequence Algorithms
copy(), remove(), replace(), fill(),
swap()
Non Modifying sequence Algorithms find(), count(),search(), mismatch(),
equal()
Numerical Algorithms
accumulate(), partial_sum(),
inner_product(), and adjacent_difference()