mirror of
https://github.com/cc65/cc65.git
synced 2025-01-14 16:33:00 +00:00
Fixed some code that adjusts an index after a deletion from a collection.
This commit is contained in:
parent
dfea22389c
commit
90b2f5aff8
@ -341,22 +341,23 @@ void CollReplaceExpand (Collection* C, void* Item, unsigned Index)
|
||||
|
||||
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
|
||||
** is the current position of the item, NewIndex is the new index before
|
||||
** the function has done it's work. Existing entries with indices NewIndex
|
||||
** and up are moved one position upwards.
|
||||
** and up might be moved one position upwards.
|
||||
*/
|
||||
{
|
||||
/* Get the item and remove it from the collection */
|
||||
/* Get the item; and, remove it from the collection */
|
||||
void* Item = CollAt (C, OldIndex);
|
||||
|
||||
CollDelete (C, OldIndex);
|
||||
|
||||
/* Correct NewIndex if needed */
|
||||
if (NewIndex >= OldIndex) {
|
||||
if (NewIndex > OldIndex) {
|
||||
/* Position has changed with removal */
|
||||
--NewIndex;
|
||||
}
|
||||
|
||||
/* Now insert it at the new position */
|
||||
/* Now, insert it at the new position */
|
||||
CollInsert (C, Item, NewIndex);
|
||||
}
|
||||
|
||||
|
@ -268,9 +268,9 @@ void CollReplaceExpand (Collection* C, void* Item, unsigned Index);
|
||||
|
||||
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
|
||||
** is the current position of the item, NewIndex is the new index before
|
||||
** the function has done it's work. Existing entries with indices NewIndex
|
||||
** and up are moved one position upwards.
|
||||
** and up might be moved one position upwards.
|
||||
*/
|
||||
|
||||
void CollMoveMultiple (Collection* C, unsigned Start, unsigned Count, unsigned Target);
|
||||
|
Loading…
x
Reference in New Issue
Block a user