Can anyone help me with commenting lines for Leftist_heap.h ? I am learning abou
ID: 3814367 • Letter: C
Question
Can anyone help me with commenting lines for Leftist_heap.h ?
I am learning about tree and can't find what does it do... thank you.
I need simple explaination of the below line :
a ) class Leftist_heap
b ) int heap_size
c ) Leftist_heap();
d ) Leftist_heap( Leftist_heap const & );
e ) Leftist_heap &operator=( Leftist_heap );
f )
template <typename Type>
Leftist_heap<Type>::Leftist_heap():
root_node( nullptr ),
heap_size( 0 ) {
g )
template <typename Type>
void Leftist_heap<Type>::swap( Leftist_heap<Type> &heap ) {
std::swap( root_node, heap.root_node );
std::swap( heap_size, heap.heap_size );
}
template <typename Type>
Leftist_heap<Type> &Leftist_heap<Type>::operator=( Leftist_heap<Type> rhs ) {
swap( rhs );
return *this;
}
h ) template <typename T>
std::ostream &operator<<( std::ostream &out, Leftist_heap<T> const &heap ) {
return out;
}
Explanation / Answer
/**
*creates a class with name "Leftist_heap"
*/
a ) class Leftist_heap
/**
* declare heap_size as integer
*/
b ) int heap_size
/**
*default constructor
*/
c ) Leftist_heap();
/**
*constructor with argument
*/
d ) Leftist_heap( Leftist_heap const & );
/**
* & operator overloading
*/
e ) Leftist_heap &operator=( Leftist_heap );
/**
* Initially it will call Leftist_heap() method and initialize root_node to null and heap size is 0
*/
f )
template <typename Type>
Leftist_heap<Type>::Leftist_heap():
root_node( nullptr ),
heap_size( 0 ) {
/**
*calls 3 swap functions with root node as parameter,heap as parameter and heap size
*/
g )
template <typename Type>
void Leftist_heap<Type>::swap( Leftist_heap<Type> &heap ) {
std::swap( root_node, heap.root_node );
std::swap( heap_size, heap.heap_size );
}
template <typename Type>
Leftist_heap<Type> &Leftist_heap<Type>::operator=( Leftist_heap<Type> rhs ) {
swap( rhs );
return *this;
}
/**
*In the below template it outputs the heap
*/
h ) template <typename T>
std::ostream &operator<<( std::ostream &out, Leftist_heap<T> const &heap ) {
return out;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.