Skip to content
VecInsertRangeFastL

VecInsertRangeFastL

Description

Insert a range using fast (order-not-preserving) placement. L-value form. The original tail-count elements of the vector are moved past the inserted region instead of having every element after idx shifted; iteration order is no longer meaningful.

Success

Returns true. The vector length grows by count; the inserted elements occupy [idx, idx + count), and the displaced elements sit somewhere in the new tail (no defined relative order). When the vector has no copy_init handler, the count * sizeof(element) source bytes have been zeroed.

Failure

Returns false on allocation failure. Both vector and source are unchanged.

Usage example (Cross-references)

Usage examples (Cross-references)
        // Test VecInsertRangeFastL
        int fast_range[] = {110, 120, 130};
        VecInsertRangeFastL(&vec, fast_range, 3, 3);
    
        // Check that array elements are zeroed
    /// TAGS: Vec, Insert, Range, Fast
    ///
    #define VecInsertRangeFast(v, varr, idx, count) VecInsertRangeFastL((v), (varr), (idx), (count))
    
    ///
    /// TAGS: Vec, PushFront, Range, LValue, Fast, Unordered
    ///
    #define VecPushFrontArrFastL(v, arr, count) VecInsertRangeFastL((v), (arr), 0, (count))
    
    ///
    #define VecMustInsertRangeFastL(v, varr, idx, count)                                                                   \
        do {                                                                                                               \
            if (!VecInsertRangeFastL((v), (varr), (idx), (count))) {                                                       \
                LOG_FATAL("VecMustInsertRangeFastL failed");                                                               \
            }                                                                                                              \
    /// TAGS: Str, Insert, Range, LValue, Fast, Unordered
    ///
    #define StrInsertRangeFastL(str, varr, idx, count) VecInsertRangeFastL((str), (varr), (idx), (count))
    
    ///
Last updated on