#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 */
+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)
#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 */
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)
* 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);