(*
    Title: 	Singly-linked list package
    LastEdit:	"Tue May  3 16:38:23 1983"
    Author: 	Mick Jordan
		Cambridge University Computer Laboratory

    This is a generic package for handling singly-linked lists.
    The critical assumption is that the first item of a record
    to be added to the list is used as the link field.
*)

DEFINITION MODULE Slist;

FROM SYSTEM IMPORT ADDRESS, WORD;

EXPORT QUALIFIED Add, Remove, AddE, JoinE;

PROCEDURE Add(VAR listhead: ADDRESS; newelement: ADDRESS);
(*  Adds 'newelement' to the front of the list whose head is 'listhead'.
*)

PROCEDURE AddE(VAR listhead: ADDRESS; newelement: ADDRESS);
(*  Adds 'newelement' to the end of the list whose head is 'listhead'.
    The link field of 'newelement' is set to NIL.
*)

PROCEDURE Remove(VAR listhead: ADDRESS; element: ADDRESS);
(*  Removes 'element' from the list whose head is 'listhead'.
*)

PROCEDURE JoinE(VAR listhead: ADDRESS; newlist: ADDRESS);
(*  Adds the list headed by 'newlist' to the end of 'listhead'.
*)

END Slist .
