0001 #include "Vector/Vector.h" //借助多重继承机制,基于向量 0002 #include "DEPQ/DEPQ.h" //按照优先级队列ADT实现的 0003 0004 template <typename T> class SMMH : public DEPQ<T>, public Vector<T> { //Symmetric Min-Max Heap 0005 protected: 0006 //void heapify ( Rank n ); //Floyd's heapification 0007 public: 0008 SMMH() { insert((T) -1); } //initialized with a dummy root 0009 void insert( T ); //insert an element (duplicates accepted) 0010 T getMin() { return _elem[1]; } 0011 T & getMax() { return _size < 3 ? _elem[1] : _elem[2]; } 0012 T delMin(); 0013 T delMax(); 0014 }; //SMMH 0015