--::::::::::
--heaplpba.ads -- Heap_LPBase
--::::::::::
-- Copyright (c) 1991, 1992, 1993, 1994, 1995
-- John Beidler
-- Computing Sciences Dept.
-- Univ. of Scranton, Scranton, PA 18510
-- beidler@guinness.cs.uofs.edu
generic
type Object_Type is limited private;
with procedure Initialize (Object: in out Object_Type);
with procedure Finalize (Object: in out Object_Type);
with procedure Swap (Source, Target : in out Object_Type);
with function ">=" ( Parent, Child : Object_Type) return boolean ;
package Heap_LPBase is
type Heap_Type (Max_Size : positive) is private ;
Heap_Underflow: exception;
Heap_Overflow : exception;
procedure Initialize (Heap: in out Heap_Type);
procedure Finalize (Heap: in out Heap_Type);
procedure Insert (Heap : in out Heap_Type;
Object : in out Object_Type);
-----------------------------------------------------
-- Pre Cond : Size_Of (Heap) < Heap.Max_Heap_Size
-- Post Cond: Object is sifted into Heap
-- Exception: Heap_Overflow
-----------------------------------------------------
procedure Remove_Root (Heap : in out Heap_Type ;
Object : in out Object_Type );
-----------------------------------------------------
-- Pre Cond : Heap is not empty
-- Post Cond: Root of Heap place in Object
-- and Heap is reordered
-- Exception: Heap_Underflow.
-----------------------------------------------------
-- SELECTORS
function Empty ( Heap: Heap_Type ) return boolean;
-----------------------------------------------------
-- Returns true if Heap is empty.
-----------------------------------------------------
function No_Of_Objects ( Heap: Heap_Type) return natural;
-----------------------------------------------------
-- Returns the count of the number of objects in the
-- Heap.
-----------------------------------------------------
-- function Are_Equal (Heap_1, Heap_2 : Heap_Type) return boolean ;
private
type Heap_array is array (positive range <>) of Object_Type ;
type Heap_Pntr is access Heap_Array;
type Heap_Type (Max_Size : positive) is
record
Size : natural := 0 ;
Data : Heap_Pntr;
end record ;
end Heap_LPBase;