VecSwapItems

Table of Contents

VecSwapItems

Description

Swap items at given indices.

Parameters

NameDirectionDescription
vin,outVector to swap items in.
idx1inIndex/Position of first item.
idx1inIndex/Position of second item.

Success

return

Failure

Does not return

Usage example (Cross-references)

    /// FAILURE : Does not return
    ///
    #define StrSwapCharAt(str, idx1, idx2) VecSwapItems((str), (idx1), (idx2))
    
    ///
    // Test VecSwapItems function
    bool test_vec_swap_items(void) {
    printf("Testing VecSwapItems\n");
    
    // Create a vector of integers
    
    // Swap first and last elements
    VecSwapItems(&vec, 0, 4);
    
    // Check that the elements were swapped
    
    // Swap two elements in the middle
    VecSwapItems(&vec, 1, 3);
    
    // Check that the elements were swapped

Share :