Skip to content

VecPopFront

VecPopFront

Description

Pop item from vector front.

Parameters

Name Direction Description
v in,out Vector to pop item from.
ptr out Popped item will be stored here. Make sure this has sufficient memory to store memcopied data. If no pointer is provided, then it’s equivalent to deleting item from last position.

Usage example (Cross-references)

Usage examples (Cross-references)
                if (VecLen(vec) > 0) {
                    char *str;
                    VecPopFront(vec, &str);
                    // char_ptr_deinit is called automatically by the vector
                }
                if (VecLen(vec) > 0) {
                    Str str;
                    VecPopFront(vec, &str);
                    // StrDeinit is called automatically by the vector
                }
                if (VecLen(vec) > 0) {
                    i32 popped;
                    VecPopFront(vec, &popped);
                }
                break;
    // Test VecPopFront function
    bool test_vec_pop_front(void) {
        WriteFmtLn("Testing VecPopFront");
    
        // Create a vector of integers
        // Pop from the front
        int popped;
        VecPopFront(&vec, &popped);
    
        // Check popped value
    
        // Pop again
        VecPopFront(&vec, &popped);
    
        // Check popped value
    /// FAILURE : Returns NULL otherwise.
    ///
    #define StrPopFront(str, chr) VecPopFront((str), (chr))
    
    ///
Last updated on