authorgravatar for squeek502@hotmail.comRyan Liptak <squeek502@hotmail.com> 2025-10-29 05:11:58-07:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2025-10-29 05:11:58-07:00
log6568f0f75b900d2ee27363b2ba81bedf206a13e7
tree775a65f7dc164bc1d3cae51488504698ccf8735a
parentb409cdf63f3496032bda83a88f54a7684feab92b
parent63a45b8ecdc9e4babd883be71dde1826f32b556f
signaturebadge-check Signed by PGP key B5690EEEBB952194

Merge pull request #25705 from squeek502/linked-list-remove-docs

Document that `remove` of Singly/DoublyLinkedList relies on the node being in the list

2 files changed, 3 insertions(+), 0 deletions(-)

lib/std/DoublyLinkedList.zig+1
...@@ -105,6 +105,7 @@ pub fn prepend(list: *DoublyLinkedList, new_node: *Node) void {...@@ -105,6 +105,7 @@ pub fn prepend(list: *DoublyLinkedList, new_node: *Node) void {
105}105}
106106
107/// Remove a node from the list.107/// Remove a node from the list.
108/// Assumes the node is in the list.
108///109///
109/// Arguments:110/// Arguments:
110/// node: Pointer to the node to be removed.111/// node: Pointer to the node to be removed.
lib/std/SinglyLinkedList.zig+2
...@@ -85,6 +85,8 @@ pub fn prepend(list: *SinglyLinkedList, new_node: *Node) void {...@@ -85,6 +85,8 @@ pub fn prepend(list: *SinglyLinkedList, new_node: *Node) void {
85 list.first = new_node;85 list.first = new_node;
86}86}
8787
88/// Remove `node` from the list.
89/// Asserts that `node` is in the list.
88pub fn remove(list: *SinglyLinkedList, node: *Node) void {90pub fn remove(list: *SinglyLinkedList, node: *Node) void {
89 if (list.first == node) {91 if (list.first == node) {
90 list.first = node.next;92 list.first = node.next;