VecInsertRange
- Macro
- August 22, 2025
Table of Contents
VecInsertRange
VecInsertRange
Description
Insert array of items into vector of it’s type. By default, this uses L-value semantics (ownership transfer). Insertion index must not exceed vector length. This preserves the ordering of elements. Best to be used with sorted vectors, if the sorted property is to be preserved.
Info
If copy_init
is set, then vector will create it’s own copy of items.
Note
Ownership of items in array is transferred to vector if no copy_init
method is set. This is to prevent multiple ownership of same object, once inserted into vector. Object won’t be usable after this call if copy_init
is not set.
Parameters
Name | Direction | Description |
---|---|---|
v | in,out | Vector to insert item into |
val | in | Array of items to be inserted |
idx | in | Index to start inserting item at. |
count | in | Number of items to insert. |
Success
return
Failure
Does not return
Usage example (Cross-references)
- In
Vec.Insert.c:197
:
// Test VecInsertRange function for inserting at a specific index
bool test_vec_push_arr(void) {
printf("Testing VecInsertRange at specific index\n");
// Create a vector of integers
- In
Vec.Insert.c:230
:
// Test VecInsertRange function for inserting from another vector
bool test_vec_insert_range(void) {
printf("Testing VecInsertRange from another vector\n");
// Create a vector of integers
// This is more reliable after other operations
int arr[] = {100, 200, 300};
VecInsertRange(&vec, arr, 1, 3);
// Check vector length