RosettaCodeData/Task/Doubly-linked-list-Element-insertion/Pascal/doubly-linked-list-element-insertion-2.pas

8 lines
221 B
ObjectPascal
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
procedure realistic_insert_link( a, c: link_ptr );
begin
if a^.next <> nil then a^.next^.prev := c; (* 'a^.next^' is another way of saying 'b', if b exists *)
c^.next := a^.next;
a^.next := c;
c^.prev := a;
end;