Added DataArray::compare(...) function.
This commit is contained in:
parent
cd0125990d
commit
61b209d459
@ -8,7 +8,7 @@ namespace hgl
|
|||||||
/**
|
/**
|
||||||
* 数据阵列
|
* 数据阵列
|
||||||
*/
|
*/
|
||||||
template<typename T> class DataArray
|
template<typename T> class DataArray:Comparator<DataArray<T>>
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
@ -34,6 +34,21 @@ namespace hgl
|
|||||||
T * end ()const{return items+count;} ///<取得阵列结束地址指针
|
T * end ()const{return items+count;} ///<取得阵列结束地址指针
|
||||||
T * last ()const{return items+(count-1);} ///<取得阵列最后一个数据地址指针
|
T * last ()const{return items+(count-1);} ///<取得阵列最后一个数据地址指针
|
||||||
|
|
||||||
|
const int compare (const DataArray<T> &vil)const override
|
||||||
|
{
|
||||||
|
if(count==vil.count)
|
||||||
|
return hgl_cmp<T>(items,vil.items,count);
|
||||||
|
|
||||||
|
int cmp_count=hgl_min(count,vil.count);
|
||||||
|
|
||||||
|
int result=hgl_cmp<T>(items,vil.items,cmp_count);
|
||||||
|
|
||||||
|
if(result)
|
||||||
|
return(result);
|
||||||
|
|
||||||
|
return count-vil.count;
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user