Double Linked List: insert_at

This commit is contained in:
Philippe PITTOLI 2024-05-26 00:36:46 +02:00
parent e05af4bbf1
commit a536c5b731

View File

@ -128,9 +128,12 @@ class DoubleLinkedList(V)
i += 1 i += 1
end end
new_node.next = current.next new_node.next = current
current.next = new_node new_node.previous = current.previous
new_node.previous = current
current.previous.not_nil!.next = new_node
current.previous = new_node
@size += 1 @size += 1
new_node new_node
end end