He uses linked list in his code
Other urls found in this thread:
youtube.com
youtube.com
rg3.github.io
twitter.com
LOL
I ain't clicking that shit nigga.
>Playing: youtube.com
smh tbh famalam
You need to update (or install if you don't have it) youtube-dl.
rg3.github.io
O(n) lookup
O(1) insertion
I figured this out for you, no need to thank me.
double linked list master race
lol
What did he mean by htis?
...
smug.jpg
Bjarne the Incompetent as usual.
...
What did he mean by this?
Nice.
L O L
Enjoy your page faults and cache misses
What's wrong with linked list?
if you want to add a linked list onto another, you have the pointers change what they point to. As opposed to allocating a new buffer and copying over elements in arrays.
Your list contents are distributed all over the place in the heap. If you have a list it's pretty likely you want to parse it more than you want to arbitrarily morph it, if you have 100000 elements you may have 100000 cache misses per parse because of this. Non-cache accesses are an order of magnitude slower than cache ones. This is without mentioning the lack of arbitrary access, pointer indirection has a cost, which also means accessing the Nth element has a cost of N pointer dereferences which may all be cache misses..
Make the math from there, none of this happens with a vector. Also remember that a vector only needs to extend itself a logarithmic amount of times if you do the typical of doubling the amount of capacity when you have no space left, which makes it pretty cheap even if you are pushing elements one by one.
A list of game entities where a player arbitrarily kills a monster, leaves some alone, and the game world spawns one, then.
It'll have its niche of uses, somewhere.
Everything should go on the stack.
(Not him)
Even then you're parsing it more often than mutating it. You need to update each monster every frame whereas you only kill or spawn monsters every few frames.
That's if your game is real time. If it's turn based then the performance of such list operations doesn't really matter in the first place since you're only doing them once or twice a turn instead of hundreds of times per second.
Besides, it's entirely possible to insert/remove arbitrary elements in a contiguous array in O(1) time as long as the exact order of elements is not important (very likely in the case of game entities).