Skip to content

VecFirst

VecFirst

Description

Value of first element in vector.

Parameters

Name Direction Description
v in Vector to get first element of.

Usage example (Cross-references)

Usage examples (Cross-references)
            case VEC_CHAR_PTR_FIRST : {
                if (VecLen(vec) > 0) {
                    char *first = VecFirst(vec);
                    (void)first; // Use the result to avoid warnings
                }
            case VEC_STR_FIRST : {
                if (VecLen(vec) > 0) {
                    Str first = VecFirst(vec);
                    (void)first; // Use the result to avoid warnings
                }
            case VEC_INT_FIRST : {
                if (VecLen(vec) > 0) {
                    volatile i32 first = VecFirst(vec);
                    (void)first;
                }
        // last value starts with invalid enum's value
        if (invalid_enum.name.length) {
            last_value = invalid_enum.name.length ? invalid_enum.value : VecFirst(&entries).value;
            StrWriteFmt(&code, "    {} = {},\n", invalid_enum.name.data, invalid_enum.value);
        }
    // Test VecFirst and VecLast functions
    bool test_vec_first_last(void) {
        WriteFmt("Testing VecFirst and VecLast\n");
    
        // Create a vector of integers
    
        // Check first and last elements
        bool result = (VecFirst(&vec) == 10);
        result      = result && (VecLast(&vec) == 30);
    
        // Modify first and last elements
        VecFirst(&vec) = 15;
        VecLast(&vec)  = 35;
    /// Access first character in string
    ///
    #define StrFirst(str) VecFirst(str)
    
    ///
Last updated on