VecPushBackArrR

Table of Contents

VecPushBackArrR

Description

Push a complete array into this vector, with R-value semantics.

Note

Unlike VecPushBackArrL, this does NOT zero out the source array after insertion.

Parameters

NameDirectionDescription
vin,outVector to insert array items into.
arrinArray to be inserted.
countinNumber (non-zero) of items in array.

Success

v

Failure

Does not return on failure

Usage example (Cross-references)

    /// FAILURE : NULL
    ///
    #define StrPushBackCstr(str, cstr, len) VecPushBackArrR((str), (cstr), (len))
    
    ///
    /// FAILURE : Does not return on failure
    ///
    #define VecMergeR(v, v2) VecPushBackArrR((v), (v2)->data, (v2)->length)
    
    ///
    // Push an array to the back
    int values[] = {10, 20, 30, 40, 50};
    VecPushBackArrR(&vec, values, 5);
    
    // Check length
    // Push another array to the back
    int more_values[] = {60, 70, 80};
    VecPushBackArrR(&vec, more_values, 3);
    
    // Check length
    // Add some initial elements
    int initial[] = {10, 20, 30};
    VecPushBackArrR(&vec, initial, 3);
    
    // Create another vector with elements to insert
    IntVec src          = VecInit();
    int    src_values[] = {40, 50, 60};
    VecPushBackArrR(&src, src_values, 3);
    
    // Insert range in the middle
    // Add some elements to first vector
    int values1[] = {10, 20, 30};
    VecPushBackArrR(&vec1, values1, 3);
    
    // Create second vector
    // Add some elements to second vector
    int values2[] = {40, 50, 60};
    VecPushBackArrR(&vec2, values2, 3);
    
    // Merge vec2 into vec1
    
    // R-value array operations
    VecPushBackArrR(&vec, arr, 3);
    
    // Check that the elements were added
    // Add some initial elements
    int values[] = {10, 20, 30, 40, 50, 60, 70, 80, 90};
    VecPushBackArrR(&vec, values, 9);
    
    // Test VecDelete (regular delete)
    
    // Add elements again
    VecPushBackArrR(&vec, values, 9);
    
    // Test VecDeleteFast (fast delete)
    
    // Add elements again
    VecPushBackArrR(&vec, values, 9);
    
    // Create an L-value index to use with regular VecDelete
    // Create a small array and use count=0
    int small_arr[1] = {42};
    VecPushBackArrR(&vec, small_arr, 0);
    result = result && (vec.length == 1); // Length should not change
    
    // Clone the source vector into the destination
    VecPushBackArrR(&clone, src.data, src.length);
    
    // Check that the clone has the same data but different memory

Share :