Hello,
I have a BinaryHeap class that uses template <class Comparable> as follows:
template <class Comparable>
class BinaryHeap {
public:
explicit BinaryHeap (int capacity = 0)
const Comparable & findMin( ) const;
.........................................................
private:
int currentSize;
vector<Comparable> array;
........................................................
};
template <class Comparable>
const Comparable & BinaryHeap<Comparable>::findMin( ) const
{
if( isEmpty( ) )
throw Underflow( );
return array[ 1 ];
}
..............................................................
}
This is the BinaryHeap class from Weiss book on Data Structure.
Now, I want to create the above BinaryHeap with a struct(a). 'a' have 2 fields: a.val(double) and a.g(int). I want the heap to be ordered by a.val or the key value by which the heap to be created is a.val and also all the heap operations should be based on a.val
How can I do this???
Your help is highly appreciated!!!
Thanks!!!