ListInsertR

Table of Contents

ListInsertR

Description

Insert an r-value into list of it’s type. Insertion index must not exceed list length.

Parameters

NameDirectionDescription
lin,outList to insert item into
rvalinr-value to be inserted
idxinIndex 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)

    /// 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)
    
    ///
    
    if (idx <= list->length) {
    ListInsertR(list, value, idx);
    }
    break;

Share :