Zig 0.17.0-dev (Split by item)

This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is the Zig library itself.

remove

Remove a node from the list. Assumes the node is in the list.

Arguments: node: Pointer to the node to be removed.

DoublyLinkedList.remove
pub fn remove(list: *DoublyLinkedList, node: *Node) void

File

lib/std/DoublyLinkedList.zig:112

Code

pub fn remove(list: *DoublyLinkedList, node: *Node) void {
    if (node.prev) |prev_node| {
        // Intermediate node.
        prev_node.next = node.next;
    } else {
        // First element of the list.
        list.first = node.next;
    }

    if (node.next) |next_node| {
        // Intermediate node.
        next_node.prev = node.prev;
    } else {
        // Last element of the list.
        list.last = node.prev;
    }
}