Skip to content
VecInsertRange

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.

If copy_init is set, then vector will create it’s own copy of items.
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)

Usage examples (Cross-references)
                    }
    
                    VecInsertRange(vec, temp_strings, index, count);
    
                    // Clean up temp strings
                    }
    
                    VecInsertRange(vec, temp_strings, index, count);
                    VecDeinit(vec);
                }
        // This is more reliable after other operations
        int arr[] = {100, 200, 300};
        VecInsertRange(&vec, arr, 1, 3);
    
        // Check vector length
    // Test VecInsertRange function for inserting at a specific index
    bool test_vec_push_arr(void) {
        WriteFmt("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) {
        WriteFmt("Testing VecInsertRange from another vector\n");
    
        // Create a vector of integers
Last updated on