-- **************************************************************************** -- Programmer Name : S. Phillips -- Program Name : Linked List -- Revision Number : Rev 1.0 -- Date Created : February 20, 1990 -- Package Description : This generic package implements linked lists. The package ex- -- ports all logical operations for these lists as well as a test for list member- -- ship, a function to return the size of a list. Procedures for building, -- and deleting lists are provided as well as methods for stepping -- through each list. The generic is instantiated on the element type that the -- set will be made up of. -- **************************************************************************** generic type Element is private; package Linked_List is type list is limited private; -- This procedure adds a member to a list procedure Add_Member (X : in out list; A_Member : Element); -- This procedure tests for list membership procedure Is_Member (X : in out list; A_Member : Element; Answer : out Boolean); -- This function returns the size of the list input function list_Size (X : in list) return Integer; -- This procedure will position a 'cursor' at the first element -- of a list in preparation for walking through the entire list procedure Rewind (X : in out list); -- This procedure returns the element currently being 'pointed to' -- by the 'cursor' procedure Current_Member (X : in list; A_Member : out Element; null_member : in out boolean); -- This procedure bumps the 'cursor' to the next element in the -- list and returns this next element in a_member. procedure Next_Member (X : in out list; A_Member : out Element; end_of_list : in out boolean); -- Function to return whether or not the 'cursor' has reached the -- last element of the list function Done (X : in list) return Boolean; -- Procedure to remove all elements from a list procedure Make_Empty (X : in out list); -- Procedure which releases all storage associated with a list procedure Release (X : in out list); private type Member; type Link is access Member; type Member is record Bod : Element; Chain : Link := null; end record; type list is record Size : Integer := 0; Current_Position, Head, Tail : Link := null; end record; end Linked_list;