From:	SCOVCB::GALVIN_FX    31-JAN-1989 09:01
To:	ARISIA::EVERHART
Subj:	

with text_io; use text_io;
with UTILITY; use UTILITY; 
with UNCHECKED_DEALLOCATION;

generic
   QUEUES_NAME : string;
   type ELEMENT_TYPE is private ;
   with function RELATES_TO (X, Y : ELEMENT_TYPE)
                 return boolean is <> ; 

        ------
package QUEUES is
        ------

--   type declarations
   type QUEUE is limited private ;

--   queue operations
   procedure CREATE_QUEUE (QUEUE_REF : in out QUEUE ; 
                           QUEUE_NAME : in STRING) ;
   procedure INSERT_QUEUE (QUEUE_REF : in out QUEUE ; 
                           ELEMENT_REF : in ELEMENT_TYPE) ;
   procedure REMOVE_QUEUE_FIRST (QUEUE_REF : in out  QUEUE ;
                                 ELEMENT_REF : out ELEMENT_TYPE) ;
   procedure REMOVE_QUEUE_CURRENT (QUEUE_REF : in out QUEUE) ;
   procedure DESTROY_QUEUE (QUEUE_REF : in out QUEUE) ;

   procedure FIRST_IN_QUEUE (QUEUE_REF : in out QUEUE;
                             ELEMENT_REF : out ELEMENT_TYPE) ;
   procedure LAST_IN_QUEUE (QUEUE_REF : in out QUEUE;
                            ELEMENT_REF : out ELEMENT_TYPE) ;
   procedure NEXT_IN_QUEUE (QUEUE_REF : in out QUEUE; 
                            ELEMENT_REF : out ELEMENT_TYPE) ;
   procedure PREVIOUS_IN_QUEUE (QUEUE_REF : in out QUEUE;
                                ELEMENT_REF : out  ELEMENT_TYPE) ;

   function QUEUE_IS_EMPTY (QUEUE_REF : in QUEUE) 
                            return boolean ;
   function QUEUE_IS_AT_BEGIN (QUEUE_REF : in QUEUE) 
                               return boolean ;
   function QUEUE_IS_AT_END (QUEUE_REF : in QUEUE) 
                             return boolean ;
   function LENGTH_OF_QUEUE (QUEUE_REF : in QUEUE) 
                             return integer ;

--   queue output control operations
   procedure OUTPUT_QUEUE_REPORT ;
   procedure SET_QUEUE_REPORT_OPTION (REPORT_OPTION : in UTILITY.OPTION);
   procedure SET_QUEUE_TRACE_OPTION (TRACE_OPTION : in UTILITY.OPTION);

--   exceptions
   QUEUE_DOES_NOT_EXIST : exception ;
   QUEUE_EMPTY_ERROR : exception ;

--  private declarations
   private

      type ELEMENT_REC ;
      type ELEMENT_PTR is access ELEMENT_REC ;
      type ELEMENT_REC is
         record
            DATA : ELEMENT_TYPE ;
            PREV, NEXT : ELEMENT_PTR := null;
         end record ;

      type QUEUE_REC;
      type QUEUE is access QUEUE_REC;
      type QUEUE_REC is
         record
            LENGTH : integer := - 1;
            NAME : UTILITY.CHAR_STRING;
            TOP, BOTTOM, CURRENT : ELEMENT_PTR;
            NO_OF_ENTRIES, MAX_LENGTH : integer := 0;
            NEXT : QUEUE := null;
         end record ;

end QUEUES;
