Skip to content
VecInsertFastR

VecInsertFastR

VecInsertFastR

Description

Quickly insert item into vector. Ordering of elements is not guaranteed to be preserved. This call makes significant difference only for sufficiently large vectors and when idx is quite less than (v)->length.

Insertion time is guaranteed to be constant for same data types.

Usage is exactly same as VecInsert, just the internal implementation is different.

Parameters

Name Direction Description
v in,out Vector to insert item into
lval in r-value to be inserted
idx in Index to insert item at.

Success

return

Failure

Does not return

Usage example (Cross-references)

Usage examples (Cross-references)
        // Use a temporary variable to avoid r-value issues
        int temp = 99;
        VecInsertFastR(&vec, temp, 2);
    
        // Check vector length
        // Try inserting just one element first with fast insert
        int single_val = 42;
        VecInsertFastR(&vec2, single_val, 2);
    
        result = result && (vec2.length == 6);
    
        // Test R-value fast insert
        VecInsertFastR(&vec, LVAL(60), 1);
    
        // Check that the element was inserted
    /// idx[in]   : Index to insert item at.
    ///
    #define VecInsertFast(v, lval, idx) VecInsertFastR((v), (lval), (idx))
    
    ///
Last updated on