VecInsertRange

Table of Contents

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

NameDirectionDescription
vin,outVector to insert item into
valinArray of items to be inserted
idxinIndex to start inserting item at.
countinNumber of items to insert.

Success

return

Failure

Does not return

Usage example (Cross-references)

    // 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
    // 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

Share :