API Reference

type Context_Data

  
   package Implementation is new ASCL.Data_Structures.Queue_Bounded_Unprotected  
      (Element => Element, Assign => Assign);  
  
   type Context_Data is tagged null record;  

type Action_Ptr is access procedure

   type Action_Ptr is access procedure (Item     : in out Element;   
                                        Context  : in out Context_Data'Class;  
                                        Continue :    out Boolean);  

Since we can't have generic protected subprograms, we use this type for Iterate. This means the actual procedure passed to Iterate must be declared at the library level to pass accessibility checks.

procedure Clear;

      procedure Clear;   

Makes the queue empty.

Contents of the queue are lost. The queue is initially empty.

Time: O(1).

procedure Put

      procedure Put (Item : in Element); -- raise Full.   

Adds Item to the queue.

Raises Full the queue is already full. The queue is unchanged if Full is raised.

Time: O(1).

Precondition: not Is_Full raise Full if violated.

procedure Get

      procedure Get (Item : in out Element); -- raise Empty.   

Removes the next Element from the queue and puts it in Item. Raises Empty if the queue is empty.

The queue is unchanged if Empty is raised.

Contents of Item are undefined if Empty is raised.

Time: O(1).

Precondition: not Is_Empty raise Empty if violated.

function Is_Full

      function Is_Full return Boolean;   

Returns True if the queue is full; False otherwise.

function Is_Empty

      function Is_Empty return Boolean;   

Returns True if the queue is empty; False otherwise.

function Length

      function Length return Natural;   

Returns the number of Elements in the queue.

function Peek

      function Peek return Element;   

Returns the Element at the head of the queue without altering the queue.

Raises Empty if the queue is empty.

Time: O(1).

procedure Iterate

      procedure Iterate   
         (Action : in Action_Ptr; Context : in out Context_Data'Class);  

Applies Action to each Element in the queue in turn, from head to tail. Iterate returns immediately if Action sets Continue to False (remainder of queue is not processed).