VecInsertRangeR

Table of Contents

VecInsertRangeR

Description

Insert array of items into vector, with R-value semantics. 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

Unlike VecInsertRangeL, this does NOT zero out the source array after insertion regardless of copy_init settings. Use this for temporary arrays or when you need to maintain the source array.

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)

    /// FAILURE : Does not return
    ///
    #define StrInsertCstr(str, cstr, idx, len) VecInsertRangeR((str), (cstr), (idx), (len))
    
    ///
    /// FAILURE : NULL
    ///
    #define StrPushCstr(str, cstr, len, pos) VecInsertRangeR((str), (cstr), (pos), (len))
    
    ///
    /// FAILURE : Does not return on failure
    ///
    #define VecPushBackArrR(v, arr, count) VecInsertRangeR((v), (arr), (v)->length, (count))
    
    ///
    /// FAILURE : Does not return on failure
    ///
    #define VecPushFrontArrR(v, arr, count) VecInsertRangeR((v), (arr), 0, (count))
    
    ///
    // Push an array at a specific index
    int values[] = {30, 40, 50};
    VecInsertRangeR(&vec, values, 1, 3);
    
    // Check length
    
    // Insert range in the middle
    VecInsertRangeR(&vec, src.data, 1, src.length);
    
    // Check length

Share :