去掉height的无用参数
This commit is contained in:
@@ -49,7 +49,7 @@ namespace TinySTL{
|
|||||||
|
|
||||||
bool empty()const{ return root_ == 0; }
|
bool empty()const{ return root_ == 0; }
|
||||||
size_t size()const{ return size_; }
|
size_t size()const{ return size_; }
|
||||||
size_t height()const{ return height_aux(root_, 0); }
|
size_t height()const{ return height_aux(root_); }
|
||||||
const_iterator root(){ return const_iterator(root_, this); }
|
const_iterator root(){ return const_iterator(root_, this); }
|
||||||
|
|
||||||
const_iterator cbegin(){ return find_min(); }
|
const_iterator cbegin(){ return find_min(); }
|
||||||
@@ -71,7 +71,7 @@ namespace TinySTL{
|
|||||||
nodeAllocator::deallocate(ptr);
|
nodeAllocator::deallocate(ptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
size_t height_aux(const node *p, size_t h)const;
|
size_t height_aux(const node *p)const;
|
||||||
void erase_elem(const T& val, node *&ptr);
|
void erase_elem(const T& val, node *&ptr);
|
||||||
void insert_elem(const T& val, node *&ptr);
|
void insert_elem(const T& val, node *&ptr);
|
||||||
const_iterator find_min_aux(const node *ptr);
|
const_iterator find_min_aux(const node *ptr);
|
||||||
@@ -82,11 +82,11 @@ namespace TinySTL{
|
|||||||
void print_postorder_aux(const string& delim, std::ostream& os, const node *ptr)const;
|
void print_postorder_aux(const string& delim, std::ostream& os, const node *ptr)const;
|
||||||
};//end of bst class
|
};//end of bst class
|
||||||
template<class T>
|
template<class T>
|
||||||
size_t binary_search_tree<T>::height_aux(const node *p, size_t h)const{
|
size_t binary_search_tree<T>::height_aux(const node *p)const{
|
||||||
if (p == 0)
|
if (p == 0)
|
||||||
return h;
|
return 0;
|
||||||
else{
|
else{
|
||||||
return TinySTL::max(height_aux(p->left_, h), height_aux(p->right_, h)) + 1;
|
return TinySTL::max(height_aux(p->left_), height_aux(p->right_)) + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
template<class T>
|
template<class T>
|
||||||
|
|||||||
Reference in New Issue
Block a user