Skip to main content
gamedev.net
🔒 Locked

Sorted lists

Started by Guimo 1 reply 200+ views
Original Post
Guimo
Guimo
Hi, Does anybody knows where can I find algoritms or C code for sorted linear lists, nets, or anything that can keep items sorted? The problem is this: In an Isometric game, all the objects should be allways sorted so they can be rendered back to front. (Using 2D card only, no 3D fuinctions). I have programmed a 2D sorted net but would like to see if I someone has a sorted list with better performance. I suppose 3D programmers have something like this as they have to render front to back to reduce the rendering areas. Thank you Guimo
Kylotan
Kylotan
There are tons of sorting algorithms available if you search on Google or something. Try looking for insertion sort, radix sort, quicksort, heapsort, introsort, merge sort... and so on. It''s generally easier to do with arrays than lists, though.

[ MSVC Fixes | STL | SDL | Game AI | Sockets | C++ Faq Lite | Boost ]
wolverine
wolverine
If i understood the problem, that''s a bit hard of doing with vectors, because of insertions in the middle of other elements.

Sorted lists are a good alternative. You should also consider binary trees (insertion O(log(n)) if ballanced, getting through all the elements O(n))), only giving compensation over lists when the number of elements is reasonable.



Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.