(* 11.3 The Unbounded Queue Interface Now that the bounded queue form has been covered, let us move on to the unbounded form. The only difference between the two interface definitions is the description of the constructor Create which does not require a size parameter as did the bounded form. From the iterator form the only difference is the removal of the two iterator routines from the interface and implementation. *) DEFINITION MODULE QSUMN; (*=========================================================== Version : 1.00 03 May 1989 C. Lins Compiler : TopSpeed Modula-2 Component: Monolithic Structures - Queue (Opaque version) Non-priority Non-balking Sequential Unbounded Managed Non-Iterator REVISION HISTORY v1.00 03 May 1989 C. Lins: Initial TopSpeed Modula-2 implementation. (C) Copyright 1989 Charles A. Lins ===========================================================*) FROM ErrorHandling IMPORT (*--Type*) HandlerProc; FROM Items IMPORT (*--Type*) Item; FROM QEnum IMPORT (*--Type*) Exceptions; FROM TypeManager IMPORT (*--Type*) TypeID; (*--------------------*) (* 11.3.1 Type Declarations A queue is declared as the abstract data type, Queue. *) TYPE Queue; CONST NullQueue = Queue(NIL); (* 11.3.2 Exceptions The ModuleID uniquely identifies this module from all others. QueueError returns the most recent queue exception, or noerr if the last operation was successful. While SetHandler and GetHandler allow assignment and retrieval of exception handling routines for specific exceptions. *) CONST ModuleID = 20; PROCEDURE QueueError () : Exceptions (*-- out *); PROCEDURE SetHandler ( theError : Exceptions (*-- in *); theHandler : HandlerProc (*-- in *)); PROCEDURE GetHandler ( theError : Exceptions (*-- in *)) : HandlerProc (*-- out *); (* 11.3.3 Constructors *) PROCEDURE Create ( theType : TypeID (*-- in *)) : Queue (*-- out *); PROCEDURE Destroy (VAR theQueue : Queue (*-- inout *)); PROCEDURE Clear (VAR theQueue : Queue (*-- inout *)); PROCEDURE Assign ( theQueue : Queue (*-- in *); VAR toQueue : Queue (*-- inout *)); PROCEDURE Arrive (VAR theQueue : Queue (*-- inout *); theItem : Item (*-- in *)); PROCEDURE Depart (VAR theQueue : Queue (*-- inout *)); (* 11.3.4 Selectors *) PROCEDURE IsDefined ( theQueue : Queue (*-- in *)) : BOOLEAN (*-- out *); PROCEDURE IsEmpty ( theQueue : Queue (*-- in *)) : BOOLEAN (*-- out *); PROCEDURE IsEqual ( left : Queue (*-- in *); right : Queue (*-- in *)) : BOOLEAN (*-- out *); PROCEDURE LengthOf ( theQueue : Queue (*-- in *)) : CARDINAL (*-- out *); PROCEDURE TypeOf ( theQueue : Queue (*-- in *)) : TypeID (*-- out *); PROCEDURE FrontOf ( theQueue : Queue (*-- in *)) : Item (*-- out *); END QSUMN.