C-Macro-Collections icon indicating copy to clipboard operation
C-Macro-Collections copied to clipboard

list.h should have a sort function

Open duarm opened this issue 2 years ago • 4 comments
trafficstars

What is the nature of this request?

  • New functionalities

Is your feature request related to a problem? Please describe.

I'm working with sprites on a game. I'll create, destroy and loop the sprites over the frame a bunch of times, and sort them only at the end, before rendering. SortedList is not suited for this since it might sort the list automatically unnecessarily. I would much rather have a list.h and manually sort at the appropriate time.

Describe the solution you'd like

have a sort function for list.h

duarm avatar Nov 02 '23 23:11 duarm

SortedList has a flag is_sorted and only gets sorted when you do operations that require it to be sorted (e.g. element access), but if you still don't want that behavior, then yes, the list.h needs a sort function.

I'll try to get back to your other feature requests as soon as possible. Thank you for the contributions!

LeoVen avatar Nov 30 '23 14:11 LeoVen

No worries, most of them are more like suggestions

duarm avatar Nov 30 '23 16:11 duarm

I've opened each feature request so we can receive feedback and decide if the change is worth including or not, I've implemented most of the changes already on my own version, so I can open PRs no problem

duarm avatar Dec 07 '23 19:12 duarm

I think it would be worth it to add an algs.h where you can template quick sorts and binary search algorithms for any data type and have the other data structures reuse the code

LeoVen avatar Dec 14 '23 01:12 LeoVen