1
0
mirror of https://github.com/cc65/cc65.git synced 2024-07-04 13:29:35 +00:00

Added CollMove

git-svn-id: svn://svn.cc65.org/cc65/trunk@797 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz 2001-07-17 11:54:30 +00:00
parent ccde3d8299
commit 5c46ebee60
2 changed files with 30 additions and 0 deletions

View File

@ -182,6 +182,29 @@ void CollDeleteItem (Collection* C, const void* Item)
void CollMove (Collection* C, unsigned OldIndex, unsigned NewIndex)
/* Move an item from one position in the collection to another. OldIndex
* is the current position of the item, NewIndex is the new index after
* the function has done it's work. Existing entries with indices NewIndex
* and up are moved one position upwards.
*/
{
/* Get the item and remove it from the collection */
void* Item = CollAt (C, OldIndex);
CollDelete (C, OldIndex);
/* Correct NewIndex if needed */
if (NewIndex >= OldIndex) {
/* Position has changed with removal */
--NewIndex;
}
/* Now insert it at the new position */
CollInsert (C, Item, NewIndex);
}
static void QuickSort (Collection* C, int Lo, int Hi,
int (*Compare) (void*, const void*, const void*),
void* Data)

View File

@ -248,6 +248,13 @@ INLINE void CollReplace (Collection* C, void* Item, unsigned Index)
(C)->Items[(Index)] = (Item))
#endif
void CollMove (Collection* C, unsigned OldIndex, unsigned NewIndex);
/* Move an item from one position in the collection to another. OldIndex
* is the current position of the item, NewIndex is the new index after
* the function has done it's work. Existing entries with indices NewIndex
* and up are moved one position upwards.
*/
void CollSort (Collection* C,
int (*Compare) (void*, const void*, const void*),
void* Data);