Skip to content

VecDeleteLast

Description

Delete the last element of the vector.

Parameters

Name Direction Description
v in,out Vector handle.

Success

Returns to the caller. The vector length shrinks by one. When copy_deinit is configured it is invoked on the dropped element.

Failure

Function cannot fail. Calling on an empty vector is a caller bug and aborts via LOG_FATAL.

Usage example (Cross-references)

Usage examples (Cross-references)
            case VEC_CHAR_PTR_DELETE_LAST : {
                if (VecLen(vec) > 0) {
                    VecDeleteLast(vec);
                }
                break;
            case VEC_STR_DELETE_LAST : {
                if (VecLen(vec) > 0) {
                    VecDeleteLast(vec);
                }
                break;
            case VEC_INT_DELETE_LAST : {
                if (VecLen(vec) > 0) {
                    VecDeleteLast(vec);
                }
                break;
    // Test VecDeleteLast function
    bool test_vec_delete_last(void) {
        WriteFmtLn("Testing VecDeleteLast");
    
        // Create a vector of integers
    
        // Delete the last element
        VecDeleteLast(&vec);
    
        // Check new length
    
        // Delete the last element again
        VecDeleteLast(&vec);
    
        // Check new length
    /// TAGS: Str, Delete, Back
    ///
    #define StrDeleteLastChar(str) VecDeleteLast(str)
    
    ///
Last updated on