Archived

This topic is now archived and is closed to further replies.

Syrillix

re-sorting a linked list

Recommended Posts

hi all, at the moment im working on a linked list which, upon object insertion, orders them by Z value from front to back... now because Z values change all the time in a game, im thinking about how to quickly resort the list so when i search the list for culling i can do a binary search because the list will be ordered.. my current idea is too get the data object pointers in the list and move them to a new list, which will automatically sort them and then delete the old list. the problem is that this will delete the memory that the data pointers pointed to. rendering this solution useless. any ideas?? thanks in advance... Get busy livin'' or get busy dyin''... - Shawshank Redemption

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Since you''re doing a binary search, you should look into using a binary search tree instead of a linked list. On a side note mergesort is a good algorithm for linked lists because it uses iterative--not random--access.

Share this post


Link to post
Share on other sites