mirror of
https://github.com/cc65/cc65.git
synced 2024-12-25 02:29:52 +00:00
New function CollTransfer. Change CollAt and CollAtUnchecked to take a const
Collection pointer instead of just a Collection pointer. This makes more sense, since the functions do not change the collection. git-svn-id: svn://svn.cc65.org/cc65/trunk@5224 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
307b8d88c3
commit
189a9bfb38
@ -167,7 +167,7 @@ void CollAppend (Collection* C, void* Item)
|
||||
|
||||
|
||||
#if !defined(HAVE_INLINE)
|
||||
void* CollAt (Collection* C, unsigned Index)
|
||||
void* CollAt (const Collection* C, unsigned Index)
|
||||
/* Return the item at the given index */
|
||||
{
|
||||
/* Check the index */
|
||||
@ -438,6 +438,26 @@ static void QuickSort (Collection* C, int Lo, int Hi,
|
||||
|
||||
|
||||
|
||||
void CollTransfer (Collection* Dest, const Collection* Source)
|
||||
/* Transfer all items from Source to Dest. Anything already in Dest is left
|
||||
* untouched. The items in Source are not changed and are therefore in both
|
||||
* Collections on return.
|
||||
*/
|
||||
{
|
||||
/* Be sure there's enough room in Dest */
|
||||
CollGrow (Dest, Dest->Count + Source->Count);
|
||||
|
||||
/* Copy the items */
|
||||
memcpy (Dest->Items + Dest->Count,
|
||||
Source->Items,
|
||||
Source->Count * sizeof (Source->Items[0]));
|
||||
|
||||
/* Bump the counter */
|
||||
Dest->Count += Source->Count;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CollSort (Collection* C,
|
||||
int (*Compare) (void*, const void*, const void*),
|
||||
void* Data)
|
||||
|
@ -122,7 +122,7 @@ void CollAppend (Collection* C, void* Item);
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_INLINE)
|
||||
INLINE void* CollAt (Collection* C, unsigned Index)
|
||||
INLINE void* CollAt (const Collection* C, unsigned Index)
|
||||
/* Return the item at the given index */
|
||||
{
|
||||
/* Check the index */
|
||||
@ -132,19 +132,19 @@ INLINE void* CollAt (Collection* C, unsigned Index)
|
||||
return C->Items[Index];
|
||||
}
|
||||
#else
|
||||
void* CollAt (Collection* C, unsigned Index);
|
||||
void* CollAt (const Collection* C, unsigned Index);
|
||||
/* Return the item at the given index */
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_INLINE)
|
||||
INLINE void* CollAtUnchecked (Collection* C, unsigned Index)
|
||||
INLINE void* CollAtUnchecked (const Collection* C, unsigned Index)
|
||||
/* Return the item at the given index */
|
||||
{
|
||||
/* Return the element */
|
||||
return C->Items[Index];
|
||||
}
|
||||
#else
|
||||
# define CollAtUnchecked(C, Index) ((C)->Items[(Index)])
|
||||
# define CollAtUnchecked(C, Index) ((C)->Items[(Index)])
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_INLINE)
|
||||
@ -274,6 +274,12 @@ void CollMoveMultiple (Collection* C, unsigned Start, unsigned Count, unsigned T
|
||||
* to higher indices.
|
||||
*/
|
||||
|
||||
void CollTransfer (Collection* Dest, const Collection* Source);
|
||||
/* Transfer all items from Source to Dest. Anything already in Dest is left
|
||||
* untouched. The items in Source are not changed and are therefore in both
|
||||
* Collections on return.
|
||||
*/
|
||||
|
||||
void CollSort (Collection* C,
|
||||
int (*Compare) (void*, const void*, const void*),
|
||||
void* Data);
|
||||
|
Loading…
Reference in New Issue
Block a user