📄 fig06_25.cpp
字号:
template <typename Comparable>
class LeftistHeap
{
public:
LeftistHeap( );
LeftistHeap( const LeftistHeap & rhs );
~LeftistHeap( );
bool isEmpty( ) const;
const Comparable & findMin( ) const;
void insert( const Comparable & x );
void deleteMin( );
void deleteMin( Comparable & minItem );
void makeEmpty( );
void merge( LeftistHeap & rhs );
const LeftistHeap & operator=( const LeftistHeap & rhs );
private:
struct LeftistNode
{
Comparable element;
LeftistNode *left;
LeftistNode *right;
int npl;
LeftistNode( const Comparable & theElement, LeftistNode *lt = NULL,
LeftistNode *rt = NULL, int np = 0 )
: element( theElement ), left( lt ), right( rt ), npl( np ) { }
};
LeftistNode *root;
LeftistNode * merge( LeftistNode *h1, LeftistNode *h2 );
LeftistNode * merge1( LeftistNode *h1, LeftistNode *h2 );
void swapChildren( LeftistNode *t );
void reclaimMemory( LeftistNode *t );
LeftistNode * clone( LeftistNode *t ) const;
};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -