mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 05:44:20 +00:00
Merge pull request #25705 from squeek502/linked-list-remove-docs
Document that `remove` of Singly/DoublyLinkedList relies on the node being in the list
This commit is contained in:
commit
6568f0f75b
2 changed files with 3 additions and 0 deletions
|
|
@ -105,6 +105,7 @@ pub fn prepend(list: *DoublyLinkedList, new_node: *Node) void {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Remove a node from the list.
|
/// Remove a node from the list.
|
||||||
|
/// Assumes the node is in the list.
|
||||||
///
|
///
|
||||||
/// Arguments:
|
/// Arguments:
|
||||||
/// node: Pointer to the node to be removed.
|
/// node: Pointer to the node to be removed.
|
||||||
|
|
|
||||||
|
|
@ -85,6 +85,8 @@ pub fn prepend(list: *SinglyLinkedList, new_node: *Node) void {
|
||||||
list.first = new_node;
|
list.first = new_node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Remove `node` from the list.
|
||||||
|
/// Asserts that `node` is in the list.
|
||||||
pub fn remove(list: *SinglyLinkedList, node: *Node) void {
|
pub fn remove(list: *SinglyLinkedList, node: *Node) void {
|
||||||
if (list.first == node) {
|
if (list.first == node) {
|
||||||
list.first = node.next;
|
list.first = node.next;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue