added SortedSets<T>::Clear function.
This commit is contained in:
@@ -271,6 +271,31 @@ namespace hgl
|
||||
return data_list.Rand(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 如果成员在clear_sets中存在,则清除它
|
||||
* @return 剩作的数据数量
|
||||
*/
|
||||
template<typename T>
|
||||
int SortedSets<T>::Clear(const SortedSets<T> &clear_sets)
|
||||
{
|
||||
if(GetCount()==0)return 0;
|
||||
if(clear_sets.GetCount()==0)return GetCount();
|
||||
|
||||
int count=data_list.GetCount();
|
||||
T *bp=begin();
|
||||
T *ep=end();
|
||||
|
||||
while(bp>=ep)
|
||||
{
|
||||
if(clear_sets.IsMember(*ep))
|
||||
data_list.DeleteMove(ep-bp);
|
||||
|
||||
--ep;
|
||||
}
|
||||
|
||||
return GetCount();
|
||||
}
|
||||
|
||||
/**
|
||||
* 求当前合集与另一个数据集的交集
|
||||
* @param result 结果存放合集
|
||||
|
@@ -59,7 +59,9 @@ namespace hgl
|
||||
bool GetBegin (T &data){return data_list.Begin(data);} ///<取得最前面一个数据
|
||||
bool GetEnd (T &data){return data_list.End(data);} ///<取得最后面一个数据
|
||||
|
||||
int Intersection (SortedSets<T> &result,const SortedSets<T> &set); ///<取得与指定合集的交集
|
||||
int Clear (const SortedSets<T> &clear_sets); ///<清除指定合集中所有数据
|
||||
|
||||
int Intersection (SortedSets<T> &result,const SortedSets<T> &sets); ///<取得与指定合集的交集
|
||||
int Intersection (const SortedSets<T> &set); ///<取得与指定合集的交集数量
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user