DEFINITION MODULE QPBSUMN;
(*===========================================================
    Version  : 1.00  04 May 1989  C. Lins
    Compiler : TopSpeed Modula-2
    Component: Monolithic Structures - Queue (Opaque version)
      Priority Balking Sequential Unbounded Managed Non-Iterator

    REVISION HISTORY
    v1.00  04 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 Relations IMPORT
    (*--Type*) Relation;

FROM TypeManager IMPORT
    (*--Type*) TypeID;

    (*--------------------*)

TYPE  Queue;
CONST NullQueue = Queue(NIL);

TYPE  Priority;
TYPE  PriorityProc    = PROCEDURE (Item) : Priority;
TYPE  PriorityCompare = PROCEDURE (Priority, Priority) : Relation;

    (*--------------------*)


CONST ModuleID = 8;

PROCEDURE QueueError () : Exceptions (*-- out   *);

PROCEDURE SetHandler (    theError   : Exceptions  (*-- in    *);
                          theHandler : HandlerProc (*-- in    *));

PROCEDURE GetHandler (    theError   : Exceptions  (*-- in    *))
                                     : HandlerProc (*-- out   *);


    (*--------------------*)

PROCEDURE Create  (    theType    : TypeID          (*-- in    *);
                       priorityOf : PriorityProc    (*-- in    *);
                       comparison : PriorityCompare (*-- 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 *));

PROCEDURE Leave   (VAR theQueue : Queue     (*-- inout *);
                       theItem  : Item      (*-- in    *));


    (*--------------------*)

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   *);

PROCEDURE PositionOf (    theQueue: Queue    (*-- in    *);
                          theItem : Item     (*-- in    *))
                                  : CARDINAL (*-- out   *);

END QPBSUMN.