authorgravatar for iokg04@gmail.comIOKG04 <iokg04@gmail.com> 2025-08-12 01:54:46+02:00
committergravatar for squeek502@hotmail.comRyan Liptak <squeek502@hotmail.com> 2025-10-25 21:10:02-07:00
loga83db33ba2d5fddcc453735a7a0d9b57c67739a8
tree99bbe12e0daf55c16dcd7dc3511378b03c3eb96b
parentbd1e960bc0d20013d9458d35318c46e40bd8ff59

`*LinkedList.remove()` assumes node is in the list

probably closes https://github.com/ziglang/zig/issues/16795

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/// Assumes `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;