Thanks for this video! I'm currently taking your C++ 2D Game Engine course, and took this detour to better understand the Vector class, since I'm coming from a web development background where everything is much more abstracted. I made an insert implementation as follow: void Insert(int index, T value){ //Handle the case where we're already at the max size before inserting if(size == capacity){ T* newArray = new T[capacity * 2]; for (int i = 0; i < size; i++){ newArray[i] = elements[i]; } delete[] elements; elements = newArray; capacity *= 2; } //Increase the size by 1 size++; //Loop over the array in reverse, setting each value equal to the one before, stopping at the given index for(int i = size - 1; i >= index; i--){ elements[i + 1] = elements[i]; } //Replace the given index with the given value elements[index] = value; } It's basic and there might be some edge cases I overlooked, but it seems to work from my testing.
@ayoubelmhamdi79202 жыл бұрын
this is one of best c/cpp vectors tutorial
@phlimma2 жыл бұрын
One more follower. I came through @Akitando channel. Very nice explanation.
@pikuma2 жыл бұрын
Welcome aboard! Abraços!!! :)
@phlimma2 жыл бұрын
@@pikuma and please accept Akita's defy to choose 3 linux distros. ;-)
@masabh2 жыл бұрын
I really should've found your youtube channel earlier. I'm doing your assembly language course on udemy too. You are a very good teacher.
@Luard-xq3zd11 ай бұрын
I recently started learning about vectors and I found this vid really helpful
@achyuththouta69572 жыл бұрын
Wow your knowledge about this is so deep. I'm trying to develop my skill and knowledge in programming as I'm a beginner in it. I've started C++ because some people said it's the hardest to learn so I thought why not? I like learning hard stuff but theres way too much in C++
@fabianrr2 жыл бұрын
Eso es lo que le falta a tu canal de KZbin, algo desde lo básico y de ahí pasar a tus cursos
@arturmg2068 Жыл бұрын
i cant belive your channel just have 10k subscribers, your videos are so good!!
@TheJGAdams2 жыл бұрын
I love how you kept the memories of the classic retro games alive. Good stuff! :) So, vector and C++ can work for console like NES? If so, that's really cool!
@pikuma2 жыл бұрын
There are many homebrew games developed in C.
@gammyhorse2 жыл бұрын
Every single one of your videos is awesome. Thank you!
@jackgame88413 ай бұрын
37:28 in lines 23 why it had a lot of const? first const and last const?
@DevSlowz2 жыл бұрын
Great content as always. Keep up the great work... ps your paid courses are amazing!
@Miura-Anjin Жыл бұрын
Thanks a lot. It makes sense now. What do you suggest me if I decide to my own implement of stack and queue?
@graemereed1951Ай бұрын
Great video. Do you know how to implement a vector class in C++ like that used in Tradestation's EasyLanguage which can accommodate multiple data types within the same vector?
@starc0w2 жыл бұрын
Dear Professor Pezzi Thanks for the video! Very well explained! If I wanted to do something like this in C. What do I have to pay attention to, besides checking whether there is enough memory (malloc). Are there things that I absolutely have to do? (You talked about the whole thing not being so trivial).
@pikuma2 жыл бұрын
Good question! We have to use a similar idea, but allocate using malloc(), reallocating/doubling size when necessary using realloc(), and freeing resources with free(). To achieve some sort of "generic" type handling with your dynamic array (for example, being able to create and manipulate different types), we could take advantage of void* and use macros to resolve the type dynamically at compile time. Thse repos are good examples of a simple dynamic array implementation in C99 using the ideas I mentioned above. github.com/eignnx/dynarray github.com/gustavopezzi/dynamicarray
@starc0w2 жыл бұрын
@@pikuma Very good, thanks for the advice and sources. I'll be happy to look at that!
@dmitrysavkin59819 ай бұрын
What about, if T doesn't have constructor? new T[2 * n] throws errror
@scalevids445710 күн бұрын
Really informative and the best in class. Anyone who want to learn must visit here. Although I had a question why regarding operator = while checking the size of rhs to our size, it should be our capacity for optimal usage. But yes that we can look and optimise anyways.
@therealherbzy2 жыл бұрын
Great video!
@preoalex8298 Жыл бұрын
What font are you using in your IDE
@dudu88games2 жыл бұрын
Ótima explicação, parabéns!
@arturmg2068 Жыл бұрын
maravilhoso!
@starc0w2 жыл бұрын
Great! Thank you Gustavo!
@baixodedata28022 жыл бұрын
tu é lindão em ..... vim pelo akita
@pikuma2 жыл бұрын
Grande Akita! :) Abração e obrigado pelo comment.
@AQFearfullMage9 ай бұрын
Thank you, this is very useful.
@wakeupneo1012 жыл бұрын
Parabéns xirú. Não conhecia teu canal, acabei chegando aqui pelo Akita. Muito bom. Inscrito e fortalecendo a comunidade.
@pikuma2 жыл бұрын
Opa James, obrigado! Um grande quebra costela. 🙂
@pablouesc2 жыл бұрын
Vim pelo Akita! Já inscrito no canal!
@pikuma2 жыл бұрын
Grande Pablo! Abraços.
@SachinHiremath-kw2rw Жыл бұрын
Nice explaination
@DanielTolentino42 Жыл бұрын
Awsome! Do you have the dotfiles of your vi setup that you can share? Thanks
@ticiusarakan Жыл бұрын
а зачем float? например 320х240 разрешение предполагает что нам не нужны знаки после запятой. или я что то недопонял?
@uanbu65392 жыл бұрын
Hi Gustavo, do you have a video about socket programming using c++?
@Dannnneh2 жыл бұрын
The title made me think this would be an in-depth look at the machinations of how the standard library's vector _really_ works, but this is a very basic introduction. Your element-removals do not even call any potential destructor :/
@desossandoTI2 жыл бұрын
Very good !!! thanks!
@AurelianBuia Жыл бұрын
what font do you use?
@pikuma Жыл бұрын
IBM's Code Page 437
@AurelianBuia Жыл бұрын
@@pikuma thank you!!
@danilonascimento35452 жыл бұрын
vim pelo akita, gostei muito do canal parabéns.
@pikuma2 жыл бұрын
Grande Danilo! Obrigado.
@katrielaraujo50902 жыл бұрын
Seu canal parece muito legal o Akita indicou e estou gostando
@abrorabyyu62212 жыл бұрын
this person is cool af
@lucassamuel60692 жыл бұрын
I'm sure your first language is portuguese, are you brazilian?
@pikuma2 жыл бұрын
yes
@lucassamuel60692 жыл бұрын
@@pikuma Cool, I know you didn't ask, but I'm studying Computer Engineering at UTFPR in Paraná-BR
@pikuma2 жыл бұрын
@@lucassamuel6069 Haha. Que legal. Eu tenho vários amigos por lá. Sou do RS. 🙂
@leandrocastro12912 жыл бұрын
Gustavo, tenho uns cursos seus na Udemy e fiquei desconfiado quando vi um chimarrao em uma das aulas haha. Vc é fera, ensina muito bem.
@mateivoican11 ай бұрын
void Insert(int index, T value){ if (size == capacity){ T* newarr = new T[capacity*2]; for (int i = 0; i index; i--) { elements[i] = elements[i-1]; } elements[index] = value; size++; }
@antoinedevldn2 жыл бұрын
The internet needs to know what you are drinking in this crazy glass!