C++ STD Gems [Sorting]

preview_player
Показать описание
Some useful tools from the C++ standard library.

Рекомендации по теме
Комментарии
Автор

Man I am at Intermediate and I can't fucking wait to watch the Direct3D series! Your vids are so mfucking cool, Chili!

bidkonic
Автор

I had no idea about partial sort, thanks for the video!

AhmadIsHungry
Автор

I got used that the last sentence is: "And I'll see you soon with some hardware 3D". ^_^
Great video Chili! Would love to see some more std gems. Especially binary search tree algorithms. Thanks a lot!

giladreich
Автор

Snorting that chilitomatonoodle seasoning powder, oh man that things gets me high.

rajul
Автор

@ChiliTomatoNoodle sort by nth element, it might be possible that you want a list of nth elements but not in order. Philosophy: grading diamonds; first 100 smallest diamonds and the diameter for that grade. Several partitions may be needed but not necessarily an ordered partition just a graded partition. Concrete example: you want to know the nth highest scoring student for 6 partitions of the total number of enrolled students but you have a million students enrolled; just want to know the general spead of those million students.

space
Автор

I know there is another algorithm for what I'm about to explain, but if nth_element partitions the range where all things less than the value at the nth element come before and everything greater comes after, then


* you could also use it to sort your game entities by health looking for any that have health less than 0, erase all elements before the nth element.
* determine which objects are in range of an area of effect attack
* gather object within a certain distance from each other to decide which objects need to have collision correction algorithms applied.


* you could sort a list of user accounts based on warnings, the nth element could be the thresh hold for a ban. Instead of creating a separate list for banned and active players, you have your giant list and only work with the range above or below the thresh hold.


Partitioning your range sounds quite useful for quite a few things actually, but I guess there is already std::partition for that so not sure for what you'd use std::nth_element over std::partition.

MrAlbinopapa
Автор

running in incognito, so no one finds out hes looking at c++

Conqueror
Автор

Chili, this may invade your privacy, but don't you want to use some custom syntax highlighting? Isn't all the white and g(r)ay kinda boring?

xAwesomeLetsPlaysx
Автор

Does it sort out the shit in my brain?

Dexterx
Автор

I used a stable bubble sort algorithm because i wanted true deterministic behaviour. Yes it's shitty performance. But i wanted the "Time" of sorting to be deterministic, and the sorting MUST be stable, because of the "struct" with the int ID needs to be stable when i sort the struct based on it's parameters. So yes, there is no silver bullit algorithm. Always use the one that is best for your problem. Though learned something new about the functor(or lambda) that you could input your "greater" or "less than" functor into it. Nice.

HermanWillems