mirror of
https://github.com/cc65/cc65.git
synced 2024-12-25 02:29:52 +00:00
Added a sort function
git-svn-id: svn://svn.cc65.org/cc65/trunk@418 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
cb762d9d7c
commit
0899e279b3
@ -33,6 +33,7 @@
|
||||
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/* common */
|
||||
@ -164,7 +165,7 @@ const void* CollConstAt (const Collection* C, unsigned Index)
|
||||
/* Check the index */
|
||||
PRECONDITION (Index < C->Count);
|
||||
|
||||
/* Return the element */
|
||||
/* Return the element */
|
||||
return C->Items[Index];
|
||||
}
|
||||
|
||||
@ -224,4 +225,15 @@ void CollReplace (Collection* C, void* Item, unsigned Index)
|
||||
|
||||
|
||||
|
||||
void CollSort (Collection* C, int (*Compare) (const void*, const void*))
|
||||
/* Sort the collection using the given compare function.
|
||||
* BEWARE: The function uses qsort internally, so the Compare function does
|
||||
* actually get pointers to the object pointers, not just object pointers!
|
||||
*/
|
||||
{
|
||||
/* Use qsort */
|
||||
qsort (C->Items, C->Count, sizeof (void*), Compare);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -113,6 +113,12 @@ void CollReplace (Collection* C, void* Item, unsigned Index);
|
||||
* just the pointer will et replaced.
|
||||
*/
|
||||
|
||||
void CollSort (Collection* C, int (*Compare) (const void*, const void*));
|
||||
/* Sort the collection using the given compare function.
|
||||
* BEWARE: The function uses qsort internally, so the Compare function does
|
||||
* actually get pointers to the object pointers, not just object pointers!
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/* End of exprlist.h */
|
||||
|
Loading…
Reference in New Issue
Block a user