ListInsertR
- Macro
- October 8, 2025
Table of Contents
ListInsertR
ListInsertR
Description
Insert an r-value
into list of it’s type. Insertion index must not exceed list length.
Parameters
Name | Direction | Description |
---|---|---|
l | in,out | List to insert item into |
rval | in | r-value to be inserted |
idx | in | Index to insert item at. |
Usage example (from documentation)
// the data
int x = 10;
int y = 20;
// vector
List(int) integers = VecInit();
// insert items
ListInsertR(&integers, x, 0); // x remains 10, unlike 0 in ListInsertL, two copies of x
ListInsertR(&integers, y, 0); // y remains 20, unlike 0 in ListInsertL, two copies of y
ListInsertR(&integers, 5, 1);
Success
return
Failure
Does not return
Usage example (Cross-references)
- In
Insert.h:135
:
/// FAILURE: Does not return.
///
#define ListPushFrontR(l, rval) ListInsertR((l), (rval), 0);
///
- In
Insert.h:146
:
/// FAILURE: Returns `NULL` otherwise.
///
#define ListPushBackR(l, rval) ListInsertR((l), (rval), (l)->length)
///
- In
ListInt.c:62
:
if (idx <= list->length) {
ListInsertR(list, value, idx);
}
break;