mirror of
https://github.com/cc65/cc65.git
synced 2024-07-07 04:29:01 +00:00
Added CollMove
git-svn-id: svn://svn.cc65.org/cc65/trunk@797 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
ccde3d8299
commit
5c46ebee60
@ -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,
|
static void QuickSort (Collection* C, int Lo, int Hi,
|
||||||
int (*Compare) (void*, const void*, const void*),
|
int (*Compare) (void*, const void*, const void*),
|
||||||
void* Data)
|
void* Data)
|
||||||
|
@ -248,6 +248,13 @@ INLINE void CollReplace (Collection* C, void* Item, unsigned Index)
|
|||||||
(C)->Items[(Index)] = (Item))
|
(C)->Items[(Index)] = (Item))
|
||||||
#endif
|
#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,
|
void CollSort (Collection* C,
|
||||||
int (*Compare) (void*, const void*, const void*),
|
int (*Compare) (void*, const void*, const void*),
|
||||||
void* Data);
|
void* Data);
|
||||||
|
Loading…
Reference in New Issue
Block a user