type
ITEM is
record
ORDER_NUM : INTEGER;
ITEM_CODE : INTEGER;
QUANTITY : INTEGER;
ITEM_TYPE : CHARACTER;
end record
;
constant
ITEM :=
(ORDER_NUM | ITEM_CODE | QUANTITY => 0, ITEM_TYPE => ` `); procedure
INSERT (NEW_ITEM : in
ITEM);
procedure
RETRIEVE(FIRST_ITEM : out
ITEM); exception
; -- raised by INSERT when table full
end
;
package body
TABLE_MANAGER is
SIZE : constant
:= 2000;
subtype
INDEX is
INTEGER range
0 .. SIZE; type
INTERNAL_ITEM is
record
CONTENT : ITEM;
SUCC : INDEX;
PRED : INDEX;
end record
;
array
(INDEX) of
INTERNAL_ITEM;
FIRST_BUSY_ITEM : INDEX := 0;
FIRST_FREE_ITEM : INDEX := 1; function
FREE_LIST_EMPTY return
BOOLEAN is
... end
;
function
BUSY_LIST_EMPTY return
BOOLEAN is
... end
;
procedure
EXCHANGE (FROM : in
INDEX; TO : in
INDEX) is
... end
; procedure
INSERT (NEW_ITEM : in
ITEM) is
begin
if
FREE_LIST_EMPTY then
raise
TABLE_FULL;
end if
;
-- remaining code for INSERT
end
INSERT; procedure
RETRIEVE (FIRST_ITEM : out
ITEM) is
... end
; begin
-- initialization of the table linkages
end
TABLE_MANAGER;