Skip to content

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)

Usage examples (Cross-references)
    
                if (idx <= list->length) {
                    ListInsertR(list, value, idx);
                }
                break;
    /// FAILURE: Does not return.
    ///
    #define ListPushFrontR(l, rval) ListInsertR((l), (rval), 0);
    
    ///
    /// FAILURE: Returns `NULL` otherwise.
    ///
    #define ListPushBackR(l, rval) ListInsertR((l), (rval), (l)->length)
    
    ///
Last updated on