Function insertAfter [src]
Prototype
pub fn insertAfter(list: *DoublyLinkedList, existing_node: *Node, new_node: *Node) void
Parameters
list: *DoublyLinkedList
existing_node: *Node
new_node: *Node
Source
pub fn insertAfter(list: *DoublyLinkedList, existing_node: *Node, new_node: *Node) void {
new_node.prev = existing_node;
if (existing_node.next) |next_node| {
// Intermediate node.
new_node.next = next_node;
next_node.prev = new_node;
} else {
// Last element of the list.
new_node.next = null;
list.last = new_node;
}
existing_node.next = new_node;
}