0% found this document useful (0 votes)
76 views

C++ STL

This document provides examples of using various C++ container types including vectors, stacks, queues, maps, and sets. It demonstrates how to initialize, access, modify, and iterate over elements in each container. Key functions and operations are explained such as push, pop, emplace, begin, end, size, empty, front, back and more. Algorithms for sorting and searching container elements are also presented.

Uploaded by

utkarsh jaiswal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
76 views

C++ STL

This document provides examples of using various C++ container types including vectors, stacks, queues, maps, and sets. It demonstrates how to initialize, access, modify, and iterate over elements in each container. Key functions and operations are explained such as push, pop, emplace, begin, end, size, empty, front, back and more. Algorithms for sorting and searching container elements are also presented.

Uploaded by

utkarsh jaiswal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

Date

Page

Notes Made DY
RITI NMar
Paius o o tet valur inambaini)

a i kint intp 2
Cout<p-itt p .p. Aecomd

STL 13
paiiu o pa

pai int paiMkink pz {1, 13,23-


0ud p kst p.sucond piuut k pLomd.seoond
3 2

P:kat PLepmd

paix oaunaA

Cout k au). Alcond,


2
Dara

Paa

*Vecto
hTay00Lnt piuouidu dyma mAe allotation
Ah ddaino
h

Verte Aint> V / dsine a nullwder

v.pushback(D Siouel

V emplaCbock l1)

Vetbo a paix
Veeto paiu kint,int> ve.
vecpLLh baek,(} 1,2}); lpushbock luu cundybathd
Vec emplace backCL,2); Sn empkac hack Culy

inno pain sF

Ltant aurioo guem ing uoith luey


damg sOm vau
elomant

velo unt 5), IIA welsu i 5 u atid.


tooo,0o
Vuta Kimt vatv)

GtatoApeuntug
tsakou
te a
gwea adds Dtakien
Cdm bL plahd ont L back
Jt+t& it--. a
Nte Kimt i
ihuatn it
ttt V.baginC)

1 1 A
t+ t +2

o 20o 30

TUnd) V/ biginO Vkhtn)VendC)


pounts to psint to C mory adAAe
t0 enacy tt to

vou dmt want y0u dAats o


w A
chamge 0u

Contant
Acc sding tlumuMl utheut ienatok

Sinolning imul an a that su a a

vlo Vato)

out
ze vbackt), " 9p >3o
ways Lo punt thL Vecto

Jau (vertau < imt itsato ite v.begin.O, itle V nd

Cout < alit) <<

A ou laute it :
vbigin), it Vendl
=
tt)

Jo aute it v) i o eachloop
Caut it
4 mouu tuoupn tha otument & not th itmatu
0ute
Automatitally couuds Ja the Quem
gum ata tye
DOTE .

Poge

L lo_0 30 t0
NRaLlv htainl))

lo 1D 12 23 35
V.uAA hapinL)t 2, vbLgiml+

alpa ia mALutiAR olumort ata giuem


plac

VectoAmd vl100) D0, LD

VAmde t Lu.bagint)+l, 2

nAhima a Lopy weto im vecto w

Veh mt Lepy50) L So,so


Vnallt Vhagialljcopu agial), Dgyord);-
I

5050,3,1o,10,1,lon
Si
Cout siU)- pt.o,1
eaamg t h laat 2lmmt
0
Vpopback) 0

appima VEto

VISunlv2)-
b, an

V.auU,-

empy6 not

liat btou th ellmund 'in aL_dymamie hoshier


vdo om at back
Jiat unt Ls
pulh-oprtO
LpuLan mck2) I 2 o-ontt)
smplocelatk(4) pUsh-backt
s puAhAnt L5) 3
enpaHontl6.
5 5 , 441
1 * -bak)
1 9LLat kunetion &amt a ein

mb

Cola b puheA hot as usell a m slh back

ActeAs 1ktend denaunt duuct4 dahontl)


da
dgue int> d

ph-hack
d4 mploa.ce beck O) I{L1}-
04pah- mt. (+). t , 2-
da tnplaneot (3),L3,4121
da ap-bazk) A3,4
dap-and, 1t
dgoarkC), I laa elameat
iatalmmt
Ret u m alLL LOmA
ein end, biaim emd, ka mlt

Atack CLIFo)Jaot im i t out


lumunda
uah pop epeut+Ms (A puvshs
theni)

Spusht); _u {1}
t push l), 2)
Stpusht3); I3,2, 3
34 pushl 3) 3,3, 2 , - ,
emploe L5) I 5,3, 3, 2

puma 5

No andAm 0cs 'u allotud. S t S J walid

arattpop 3,3,21},

Cot St &mptyO; I Stask u ampy o nt


&tack mt stl
Stak4ind >st2;

t &uoap (st2)
A dDun a ttanatsh k hgm Rnd
Aoma0s tosk
)mited fumdi pmoliuu
onoami m if
Jast nA d
elenpmt at thi tnp rathan i t u th
ut mntid elummant al th o
quu kint as

aaplacs4), IL2,t

(outdq back);1f

Juont plomamt

Oput ahent 1

Pouiouiby_qUL StaStauu th dmunt in


d ahinm n deACUnding 0uda
Ha h
Dgta

PLiaity-qul i n t ì pay"

PapLahl5);
PRshla) I S S,2}
p4puth6),15 , 2
pqpLLhl1o); I1 0 , 6 5,21
1o
Csuut spa: top
ne, 5,21-
Cout Le pq top U- 8

O0p emptu umttton auL dam 04 Atoek


3qu

to)
pusty quuu int, veboukimt z uatuu Lumi>>pA
pa psh (S)
pa push ()
pA PLuh 8) 2,5, 81
PA emplace (io) 2, 5,A,lo?

Cout ptopu 1unti R.


A Moue temamd in a AuALd_adou
unt a4 minti omly

e int St
mgt (1)
ompko.co (2) 1,2}
mald (2) ,notak mis 2, a it
At tmAod(4 kas +okom.
Atmaud 3 ;
{1,1, t}
2,3,4
bagin )emdt) ubagin ) emd O, siy)
mpty ) mpt) ouu L0mo as thoAL
Obou

23,t, 5
auto it z st irdla);
but wham whimd th umu whih.u nst
p nd in aot, it o6uld point w
end Omamd
Juki
aLLO = t n d (s)

1213 14 ls
kimd(a) IE Sod
e l i i d u poAMt un A

Il AAs S O Losn)
mt tnt tconk C);
Date
Paoe

ALAt)_gt 2 elAl Cnt =0

3 t, 5
Quke it l= St:kirdl)
Qauto ita= ukindLA)
S AL itl, it2)

h akta esLaAL 1, t5 Lkuut, last)

hyJGLk m_dhe
doe

Chsk X LAad in L0tad. ara a1a BAmot-

Jbos us E bimauy- uaMeh a,Qtm,33)

L45
at
Date
Page

Muldiset » bmulau as L b u tallouA e ttoue


duplicaiL lumamt thad n &suted oud)L

multaot kint? ms-


ns Unatuet L); 1
mS
mS inaut ) 1 L,1, 1}

myadimgle om eLaaid
ns euaal (ms indo)
mS: euaas ms ndC msimd\)+21,
n tindh tAumt ha he im
qiuenAd
Unt ond msCsmt U).
est all unttron asu me aa dU.

Un&udund -et om uumettonality asi


D tpA uniqu OlLmamtu

Jeue bBLmd LuPR bomd u net opplicoble


Map
AMap Atouu lmawtds in We&vauo pai
ke,valu

map int,int Mpp


map t passLimty mt >> mpp
ma painkint unyint > mpP

mppi-2 to wti allao valu


TMPDUnARut

L, 1toLd im ADtLd

O (auo mpe)

Je asN h valus
wen Kuy
Cot apLil
ma-O(Lotn) Dote
Puge

kind untkien
uts t mppind (3);

pounth 10 Lh poLtraDn ahu 8 homd


hO phima th ValL

Am

Auloit2 npp.leu bAumd C2),


Aute t z mpe upAL beumd(a);-

KMultmap ktsluA 0giun VY tueLAL


mDLL Aimai mutiple_v valuu4al
UngdhAd map -_tOHLOA emda Om
amhun but LelliALom Could faka
la
Date
Paga

SOLut Agouithm
_Sot_jm AAAOMdina
Aout a Ato)- Ld

LBLLt (at2, att); iust last

AOLt La, atn, atauLint 2) 1LALt in dAAROmdir


0do4

"|lOmpakaLou

bos Lemp (pau kint, imt~ p uk umdpLmt2pu


itlpicacond ap SecDmd)getuni
twn t
rtum alae ,
o4Lintint alja

Ashng it arc d elimn

A L o n d elomsmt han LAt t aeAy


hLst elemB but m dagonduma ada
Dote
Page

buittm- paptoumtC)-LoUnds kh vo:oAt


itn in bimitL0AAOn+0Aian n
tony wouki fau untog2
t num= t I1
u t nt --biiltim-paptsLnt)

Ung lenahum E 65712 6ST868


int comd -buik in-pAp c0LLmtO

ntAMmutatron- q i thl nax dickieray

23
-d
Cut s L d t
kiu naatpixmutatian (&ihigin) sndot
123
13

1 31 2

Uvil maiE * nma-


elmint la Qtn)

You might also like