Iterator Invalidation | C++ STL (Standard Template Library)

  Рет қаралды 9,762

Knowledge Center

Knowledge Center

Күн бұрын

Пікірлер: 5
@adityadhole879
@adityadhole879 3 жыл бұрын
Thanks for explanation !!
@KnowledgeCenter
@KnowledgeCenter 3 жыл бұрын
Welcome.
@miraihajar2584
@miraihajar2584 Жыл бұрын
why the *it value got 5 when its 100
@obww306
@obww306 Жыл бұрын
you didn't get that?
@vickymar3836
@vickymar3836 5 ай бұрын
This video did not explain properly. For vectors, insertion may cause reallocation of memory to different set of contiguous memory (since vectors are dynamic arrays) and if you insert an element the system will have to copy the whole vector to a new location with some empty memory at the end to allow further size change without copy. When that happens the whole vector gets invalidated. That is what happened here. Otherwise if this would not have happened, e.g. when insertions are done when there is space remaining *it would have given 100 and iterator would not have got invalidated and only the end iterator of the vector would have got invalidated cause itis now not pointing to the end. Invalidation means that you can now not access the vector properly using the iterator.
Vector | C++ STL (Standard Template Library) | std::vector
18:25
Knowledge Center
Рет қаралды 16 М.
List | C++ STL (Standard Template Library) | std::list
24:19
Knowledge Center
Рет қаралды 19 М.
Sigma Kid Mistake #funny #sigma
00:17
CRAZY GREAPA
Рет қаралды 30 МЛН
How to treat Acne💉
00:31
ISSEI / いっせい
Рет қаралды 108 МЛН
1% vs 100% #beatbox #tiktok
01:10
BeatboxJCOP
Рет қаралды 67 МЛН
Мясо вегана? 🧐 @Whatthefshow
01:01
История одного вокалиста
Рет қаралды 7 МЛН
A Deep Dive Into Iterators and Itertools in Python
21:01
ArjanCodes
Рет қаралды 62 М.
you will never ask about pointers again after watching this video
8:03
Set | C++ STL (Standard Template Library) | std::set 🔥
24:10
Knowledge Center
Рет қаралды 11 М.
15 Years Writing C++ - Advice for new programmers
4:04
SyncMain
Рет қаралды 1,3 МЛН
Map In C++
13:54
CppNuts
Рет қаралды 139 М.
Sigma Kid Mistake #funny #sigma
00:17
CRAZY GREAPA
Рет қаралды 30 МЛН