ListRemove

Table of Contents

ListRemove

Description

Remove item from list at given index and store in given pointer. Order of elements is guaranteed to be preserved.

Parameters

NameDirectionDescription
lin,outList to remove item from.
valoutWhere removed item will be stored. If not provided then it’s equivalent to deleting the item at specified index.
idxinIndex in list to remove item from.

Success

Returns v on success.

Failure

Returns NULL otherwise.

Usage example (Cross-references)

    /// FAILURE : Returns `NULL` otherwise.
    ///
    #define ListPopFront(l, val) ListRemove((l), (val), 0);
    
    ///
    /// FAILURE : Returns NULL otherwise.
    ///
    #define ListPopBack(l, val) ListRemove((l), (val), ((l) ? (l)->length - 1 : (size_t)-1));
    
    ///
    /// Delete item at given index
    ///
    #define ListDelete(l, idx) ListRemove((l), NULL, (idx))
    
    ///
    if (idx < list->length) {
    i32 removed;
    ListRemove(list, &removed, idx);
    }
    break;

Share :