**fig6_4.txt** /* 1*/ // Note: the user must supply the routine Min_Val, /* 2*/ // Which returns the minimum value of type Element_Type, /* 3*/ // Which is used as a sentinel. /* 4*/ static const Default_Max_Size = 10; /* 5*/ template /* 6*/ class Binary_Heap /* 7*/ { /* 8*/ private: /* 9*/ unsigned int Max_Size; // Maximum number of elements. /*10*/ unsigned int Size; // Current number of elements. /*11*/ Element_Type *Elements; // The array. /*12*/ Binary_Heap( Binary_Heap & Value ); // Disabled. /*13*/ public: /*14*/ // Constructor. /*15*/ Binary_Heap( unsigned int Initial_Size = Default_Max_Size ); /*16*/ // Destructor. /*17*/ ~Binary_Heap( ) { delete [ ] Elements; } /*18*/ // Operator. /*19*/ const Binary_Heap & operator = ( const Binary_Heap & Value ); /*20*/ // Member functions. /*21*/ void Make_Empty( ) { Size = 0; } /*22*/ int Is_Empty( ) const { return Size == 0; } /*23*/ int Is_Full( ) const { return Size == Max_Size; } /*24*/ void Insert( const Element_Type & X ); /*25*/ Element_Type Delete_Min( ); /*26*/ const Element_Type & Find_Min( ) const; /*27*/ }; /* 1*/ template /* 2*/ Binary_Heap:: /* 3*/ Binary_Heap( unsigned int Initial_Size ) /* 4*/ { /* 5*/ Size = 0; /* 6*/ Max_Size = Initial_Size; /* 7*/ Elements = new Element_Type [ Max_Size + 1 ]; /* 8*/ if( Elements == NULL ) /* 9*/ Error( "Out of space!!" ); /*10*/ Elements[ 0 ]= Min_Val( ); /*11*/ }