VecFirst

Table of Contents

VecFirst

Description

Value of first element in vector.

Parameters

NameDirectionDescription
vinVector to get first element of.

Usage example (Cross-references)

    // 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;
    // 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);
    }
    /// Access first character in string
    ///
    #define StrFirst(str) VecFirst(str)
    
    ///
    case VEC_INT_FIRST : {
    if (VecLen(vec) > 0) {
    volatile i32 first = VecFirst(vec);
    (void)first;
    }
    case VEC_STR_FIRST : {
    if (VecLen(vec) > 0) {
    Str first = VecFirst(vec);
    (void)first; // Use the result to avoid warnings
    }
    case VEC_CHAR_PTR_FIRST : {
    if (VecLen(vec) > 0) {
    char *first = VecFirst(vec);
    (void)first; // Use the result to avoid warnings
    }

Share :