Skip to content

ListRemove

ListRemove

Description

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

Parameters

Name Direction Description
l in,out List to remove item from.
val out Where removed item will be stored. If not provided then it’s equivalent to deleting the item at specified index.
idx in Index in list to remove item from.

Success

Returns v on success.

Failure

Returns NULL otherwise.

Usage example (Cross-references)

Usage examples (Cross-references)
                if (idx < list->length) {
                    i32 removed;
                    ListRemove(list, &removed, idx);
                }
                break;
    /// 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))
    
    ///
Last updated on