API Reference

type Handle , procedure Clear

  
   type Handle is limited private; -- Initial value: empty.  
  
   procedure Clear (Stack : in out Handle);  

Makes Stack empty.

Time: O(N).

procedure Assign

   procedure Assign (To : out Handle; From : in Handle);   

Makes To a copy of From.

May raise Storage_Exhausted.

The state of To is unknown if Storage_Exhausted is raised.

procedure Push

   procedure Push (Onto : in out Handle; Item : in Element);   

raise Storage_Exhausted.

Adds Item to the top of Onto.

Raises Storage_Exhausted if no more storage is available for Onto. Nothing is changed if Storage_Exhausted is raised.

Time: O(1).

procedure Pop

   procedure Pop (From : in out Handle; Item : in out Element); -- raise Empty.   

Removes the Element at the top of From and assigns it to Item. Raises Empty if From is empty.

Time: O(1).

Precondition: not Is_Empty (From) raise Empty if violated.

function Length

   function Length (Stack : Handle) return Natural;   

Returns a count of the number of Elements in Stack.

function Is_Empty

   function Is_Empty (Stack : Handle) return Boolean;   

Returns True if Stack is empty; False otherwise.

function Peek

   function Peek (Stack : Handle) return Element;   

Returns the Element on the top of Stack without altering Stack. Raises Empty if Stack is empty.

Time: O(1).

type Context_Data (<>) , with procedure Action , procedure Iterate

   generic -- Iterate   
      type Context_Data (<>) is limited private;  
  
      with procedure Action (Item     : in out Element;  
                             Context  : in out Context_Data;  
                             Continue :    out Boolean);  
   procedure Iterate (Over : in out Handle; Context : in out Context_Data);  

Calls Action with each Element in Over in turn, from top to bottom. Returns immediately if Continue is set to False (remainder of Over is not processed).