fixed a problem at HeapSort that the "number <=2" ????

This commit is contained in:
HuYingzhuo(hugo/hyzboy) 2023-02-03 17:43:57 +08:00
parent 39fbdef7a6
commit 0e31543779

View File

@ -3,18 +3,17 @@
#include<hgl/TypeFunc.h>
#include<string.h>
namespace hgl
template<typename T> class SortBase
{
template<typename T> class SortBase
{
protected:
protected:
T *buffer; //数据
int number; //数据个数
Comparator<T> *comp; //比较函数类
public:
public:
/**
*
@ -67,8 +66,10 @@ namespace hgl
}
virtual bool sort()=0; //排序
};//struct SortBase
};//struct SortBase
namespace hgl
{
//堆排序
template<typename T> class HeapSort:public SortBase<T>
{
@ -111,7 +112,7 @@ namespace hgl
bool sort()
{
if(!SortBase<T>::buffer||SortBase<T>::number<=2||!SortBase<T>::comp)
if(!SortBase<T>::buffer||SortBase<T>::number<2||!SortBase<T>::comp)
return(false);
int i;