Skip to content
VecPushFrontArrR

VecPushFrontArrR

Description

Prepend a contiguous range at the front of the vector. R-value form.

Success

Returns true. The vector length grows by count; copies of the source elements occupy [0, count); all previous elements have shifted right by count. The source range is untouched.

Failure

Returns false on allocation failure. The vector is unchanged.

Usage example (Cross-references)

Usage examples (Cross-references)
                        values[i] = (i32)extract_u32(data, offset, data_size);
                    }
                    VecPushFrontArrR(vec, values, count);
                }
                break;
        // Push an array to the front of empty vector
        int values[] = {10, 20, 30, 40, 50};
        VecPushFrontArrR(&vec, values, 5);
    
        // Check length
        // Push another array to the front
        int more_values[] = {60, 70, 80};
        VecPushFrontArrR(&vec, more_values, 3);
    
        // Check length
    #define VecMustPushFrontArrR(v, arr, count)                                                                            \
        do {                                                                                                               \
            if (!VecPushFrontArrR((v), (arr), (count))) {                                                                  \
                LOG_FATAL("VecMustPushFrontArrR failed");                                                                  \
            }                                                                                                              \
    #define StrPushFrontMany(...) OVERLOAD(StrPushFrontMany, __VA_ARGS__)
    #define StrPushFrontMany_2(str, zstr)                                                                              \
        _Generic((zstr), Zstr: VecPushFrontArrR((str), (Zstr)(zstr), ZstrLen((Zstr)(zstr))), char *: VecPushFrontArrR((str), (Zstr)(zstr), ZstrLen((Zstr)(zstr))))
    #define StrPushFrontMany_3(str, cstr, cstr_len)                                                                    \
        _Generic((cstr), Zstr: VecPushFrontArrR((str), (Zstr)(cstr), (cstr_len)), char *: VecPushFrontArrR((str), (Zstr)(cstr), (cstr_len)))
        _Generic((zstr), Zstr: VecPushFrontArrR((str), (Zstr)(zstr), ZstrLen((Zstr)(zstr))), char *: VecPushFrontArrR((str), (Zstr)(zstr), ZstrLen((Zstr)(zstr))))
    #define StrPushFrontMany_3(str, cstr, cstr_len)                                                                    \
        _Generic((cstr), Zstr: VecPushFrontArrR((str), (Zstr)(cstr), (cstr_len)), char *: VecPushFrontArrR((str), (Zstr)(cstr), (cstr_len)))
    
    ///
    /// TAGS: Str, PushFront, Range, RValue
    ///
    #define StrPushFrontArrR(str, arr, count) VecPushFrontArrR((str), (arr), (count))
    
    ///
Last updated on