RosettaCodeData/Task/Singly-linked-list-Element-insertion/Pascal/singly-linked-list-element-insertion-1.pascal
Ingy döt Net 68f8f3e56b all tasks
2013-04-11 01:07:29 -07:00

15 lines
573 B
Text

type
pCharNode = ^CharNode;
CharNode = record
data: char;
next: pCharNode;
end;
(* This procedure inserts a node (newnode) directly after another node which is assumed to already be in a list.
It does not allocate a new node, but takes an already allocated node, thus allowing to use it (together with
a procedure to remove a node from a list) for splicing a node from one list to another. *)
procedure InsertAfter(listnode, newnode: pCharNode);
begin
newnode^.next := listnode^.next;
listnode^.next := newnode;
end;