|ASCL User's Guide: ASCL, ADA Standard Component Library; Version 0.1.0; Document Revision $Revision: 1.7 $|
|Prev||Chapter 35. ASCL.Data_Structures.Queue_Unbounded||Next|
package Implementation is new Queue_Unbounded_Unprotected (Element => Element, Assign => Assign); type Context_Data is tagged null record;
type Action_Ptr is access procedure (Item : in out Element; Context : in out Context_Data'Class; Continue : out Boolean);
We can't have a generic protected subprogram, so we use this type to implement Iterate. This means that the actual procedure passed to Iterate must be declared at the library level to pass accessibility checks.
Makes the queue empty.
procedure Put (Item : in Element); -- raise Storage_Exhausted.
Adds Item to the queue.
Raises Storage_Exhausted if there is insufficient storage for the Element.
The queue is unchanged if Storage_Exhausted is raised.
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 has no elements.
The queue is unchanged if Empty is raised.
Contents of Item are undefined if Empty is raised.
Precondition: not Is_Empty raise Empty if violated.
function Is_Empty return Boolean;
Returns True if the queue is empty; False otherwise.
function Length return Natural;
Returns the number of Elements in the queue.
function Peek return Element;
Returns the Element at the head of the queue without altering the queue.
Raises Empty if the queue is empty.
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.