VecSwapItems
- Macro
- August 22, 2025
Table of Contents
VecSwapItems
VecSwapItems
Description
Swap items at given indices.
Parameters
Name | Direction | Description |
---|---|---|
v | in,out | Vector to swap items in. |
idx1 | in | Index/Position of first item. |
idx1 | in | Index/Position of second item. |
Success
return
Failure
Does not return
Usage example (Cross-references)
- In
Memory.h:39
:
/// FAILURE : Does not return
///
#define StrSwapCharAt(str, idx1, idx2) VecSwapItems((str), (idx1), (idx2))
///
- In
Vec.Ops.c:30
:
// Test VecSwapItems function
bool test_vec_swap_items(void) {
printf("Testing VecSwapItems\n");
// Create a vector of integers
- In
Vec.Ops.c:43
:
// Swap first and last elements
VecSwapItems(&vec, 0, 4);
// Check that the elements were swapped
- In
Vec.Ops.c:49
:
// Swap two elements in the middle
VecSwapItems(&vec, 1, 3);
// Check that the elements were swapped