renamed to Free/Clear instead of Clear/ClearData

This commit is contained in:
HuYingzhuo(hugo/hyzboy) 2023-08-14 20:01:44 +08:00
parent 252955735e
commit b0514c94e3
14 changed files with 34 additions and 34 deletions

View File

@ -140,7 +140,7 @@ namespace hgl
max_size=0; max_size=0;
} }
void ClearData() void Clear()
{ {
cur_pos=0; cur_pos=0;
buf_size=0; buf_size=0;

View File

@ -88,7 +88,7 @@ namespace hgl
} }
else else
{ {
data_list[recv_index].ClearData(); //清空接收区的数据 data_list[recv_index].Clear(); //清空接收区的数据
post_lock.Lock(); post_lock.Lock();
_Swap(); _Swap();

View File

@ -54,7 +54,7 @@ namespace hgl
{ {
lock.Lock(); lock.Lock();
proc_list.Add(join_list); proc_list.Add(join_list);
join_list.ClearData(); join_list.Clear();
lock.Unlock(); lock.Unlock();
return proc_list; return proc_list;
@ -124,7 +124,7 @@ namespace hgl
lock.Lock(); lock.Lock();
proc_list.Add(join_list); proc_list.Add(join_list);
join_list.ClearData(); join_list.Clear();
lock.Unlock(); lock.Unlock();
return(true); return(true);
@ -140,7 +140,7 @@ namespace hgl
lock.Lock(); lock.Lock();
proc_list.Add(join_list); proc_list.Add(join_list);
join_list.ClearData(); join_list.Clear();
lock.Unlock(); lock.Unlock();
return(true); return(true);

View File

@ -176,7 +176,7 @@ namespace hgl
++p; ++p;
} }
thread_set.ClearData(); thread_set.Clear();
} }
/** /**

View File

@ -134,7 +134,7 @@ namespace hgl
this->OnFinish(wt_index); this->OnFinish(wt_index);
wl.ClearData(); wl.Clear();
} }
return(true); return(true);

View File

@ -32,7 +32,7 @@ namespace hgl
Comparator<GS> comp; Comparator<GS> comp;
hgl::Sort(stop_list.GetArray(),&comp); ::Sort(stop_list.GetArray(),&comp);
dirty=false; dirty=false;
} }

View File

@ -115,8 +115,8 @@ namespace hgl
int Add(const List<T> &l){return Add(l.items,l.count);} ///<增加一批数据 int Add(const List<T> &l){return Add(l.items,l.count);} ///<增加一批数据
virtual void Free(){data_array.Free();} ///<清除所有数据 virtual void Free(){data_array.Free();} ///<清除所有数据,并释放内存
virtual void ClearData(){data_array.Clear();} ///<清除所有数据,但不清空缓冲区 virtual void Clear(){data_array.Clear();} ///<清除所有数据,但不清空缓冲区
virtual int Find(const T &data)const{return data_array.Find(data);} ///<查找指定数据的索引 virtual int Find(const T &data)const{return data_array.Find(data);} ///<查找指定数据的索引
virtual bool IsExist(const T &flag)const{return Find(flag)>=0;} ///<确认数据项是否存在 virtual bool IsExist(const T &flag)const{return Find(flag)>=0;} ///<确认数据项是否存在

View File

@ -477,7 +477,7 @@ namespace hgl
* *
*/ */
template<typename K,typename V,typename KVData> template<typename K,typename V,typename KVData>
void _Map<K,V,KVData>::Clear() void _Map<K,V,KVData>::Free()
{ {
data_pool.Clear(); data_pool.Clear();
data_list.Free(); data_list.Free();
@ -487,19 +487,19 @@ namespace hgl
* *
*/ */
template<typename K,typename V,typename KVData> template<typename K,typename V,typename KVData>
void _Map<K,V,KVData>::ClearData() void _Map<K,V,KVData>::Clear()
{ {
data_pool.ReleaseActive(); data_pool.ReleaseActive();
data_list.ClearData(); data_list.Clear();
} }
template<typename K,typename V,typename KVData> template<typename K,typename V,typename KVData>
void _Map<K,V,KVData>::operator=(const ThisClass &ftd) void _Map<K,V,KVData>::operator=(const ThisClass &ftd)
{ {
Clear(); Free();
data_pool.Clear(); data_pool.Clear();
data_list.ClearData(); data_list.Clear();
const int count=ftd.data_list.GetCount(); const int count=ftd.data_list.GetCount();
@ -602,7 +602,7 @@ namespace hgl
template<typename K,typename V,typename KVData> template<typename K,typename V,typename KVData>
void _Map<K,V,KVData>::WithList(_Map<K,V,KVData>::KVDataList &with_list,const List<K> &in_list) void _Map<K,V,KVData>::WithList(_Map<K,V,KVData>::KVDataList &with_list,const List<K> &in_list)
{ {
with_list.ClearData(); with_list.Clear();
const int count=this->GetCount(); const int count=this->GetCount();
if(count<=0)return; if(count<=0)return;
@ -626,7 +626,7 @@ namespace hgl
template<typename K,typename V,typename KVData> template<typename K,typename V,typename KVData>
void _Map<K,V,KVData>::WithoutList(_Map<K,V,KVData>::KVDataList &without_list,const List<K> &in_list) void _Map<K,V,KVData>::WithoutList(_Map<K,V,KVData>::KVDataList &without_list,const List<K> &in_list)
{ {
without_list.ClearData(); without_list.Clear();
const int count=this->GetCount(); const int count=this->GetCount();
if(count<=0)return; if(count<=0)return;

View File

@ -61,8 +61,8 @@ namespace hgl
virtual bool DeleteAt(int,int); ///<根据序号将指定数据从列表中移除 virtual bool DeleteAt(int,int); ///<根据序号将指定数据从列表中移除
virtual bool ChangeOrAdd(const K &,const V &); ///<更改一个数据的内容(如不存在则添加) virtual bool ChangeOrAdd(const K &,const V &); ///<更改一个数据的内容(如不存在则添加)
virtual bool Change(const K &,const V &); ///<更改一个数据的内容(如不存在则更改失效) virtual bool Change(const K &,const V &); ///<更改一个数据的内容(如不存在则更改失效)
virtual void Clear(); ///<清除所有数据 virtual void Free(); ///<清除所有数据,并释放内存
virtual void ClearData(); ///<清除所有数据,但不释放内存 virtual void Clear(); ///<清除所有数据,但不释放内存
KVDataList & GetList(){return data_list;} ///<取得线性列表 KVDataList & GetList(){return data_list;} ///<取得线性列表
KVData ** GetDataList()const{return data_list.GetData();} ///<取得纯数据线性列表 KVData ** GetDataList()const{return data_list.GetData();} ///<取得纯数据线性列表
@ -239,7 +239,7 @@ namespace hgl
*/ */
void UnlinkAll() void UnlinkAll()
{ {
SuperClass::Clear(); SuperClass::Free();
} }
/** /**
@ -287,7 +287,7 @@ namespace hgl
while(n--) while(n--)
DeleteObject(n); DeleteObject(n);
SuperClass::Clear(); SuperClass::Free();
} }
/** /**

View File

@ -32,16 +32,16 @@ namespace hgl
virtual void Free() override ///<清除所有数据 virtual void Free() override ///<清除所有数据
{ {
ClearData(); Clear();
List<T *>::Free(); List<T *>::Free();
} }
virtual void ClearData() override ///<清除所有数据,但不清空缓冲区 virtual void Clear() override ///<清除所有数据,但不清空缓冲区
{ {
for(auto *obj:data_array) for(auto *obj:data_array)
DeleteObject(obj); DeleteObject(obj);
List<T *>::ClearData(); List<T *>::Clear();
} }
virtual bool IsExist(const ItemPointer &flag)const override ///<确认数据项是否存在 virtual bool IsExist(const ItemPointer &flag)const override ///<确认数据项是否存在
@ -54,7 +54,7 @@ namespace hgl
virtual bool Unlink(int start,int number){return List<T *>::Delete(start,number);} ///<将指定索引处的数据与列表断开 virtual bool Unlink(int start,int number){return List<T *>::Delete(start,number);} ///<将指定索引处的数据与列表断开
virtual bool UnlinkByValue(const ItemPointer &ip){return List<T *>::DeleteByValue(ip);} ///<将一个指定数据与列表断开 virtual bool UnlinkByValue(const ItemPointer &ip){return List<T *>::DeleteByValue(ip);} ///<将一个指定数据与列表断开
virtual void UnlinkByValue(const ItemPointer *ip,int n){List<T *>::DeleteByValue(ip,n);} ///<将一批指定数据与列表断开 virtual void UnlinkByValue(const ItemPointer *ip,int n){List<T *>::DeleteByValue(ip,n);} ///<将一批指定数据与列表断开
virtual void UnlinkAll(){List<T *>::ClearData();} ///<断开所有数据 virtual void UnlinkAll(){List<T *>::Clear();} ///<断开所有数据
private: private:
@ -157,7 +157,7 @@ namespace hgl
if(new_count<=0) if(new_count<=0)
{ {
ClearData(); Clear();
return(true); return(true);
} }
@ -194,6 +194,6 @@ namespace hgl
} }
};//template <typename T> class ObjectList };//template <typename T> class ObjectList
#define OBJECT_LIST_ARRAY_CLEAR(object_list) for(auto &obj:object_list)obj.Clear(); #define OBJECT_LIST_ARRAY_FREE(object_list) for(auto &obj:object_list)obj.Free();
#define OBJECT_LIST_ARRAY_CLEAR_DATA(object_list) for(auto &obj:object_list)obj.ClearData(); #define OBJECT_LIST_ARRAY_CLEAR(object_list) for(auto &obj:object_list)obj.Clear();
}//namespace hgl }//namespace hgl

View File

@ -51,7 +51,7 @@ namespace hgl
Clear(obj->value); Clear(obj->value);
} }
items.Clear(); items.Free();
} }
virtual void ClearFree() ///<清除所有引用计数为0的对象 virtual void ClearFree() ///<清除所有引用计数为0的对象

View File

@ -175,14 +175,14 @@ namespace hgl
dlc->OnIdle(Active.GetData(),Active.GetCount()); dlc->OnIdle(Active.GetData(),Active.GetCount());
Idle.Push(Active.GetData(),Active.GetCount()); Idle.Push(Active.GetData(),Active.GetCount());
Active.ClearData(); Active.Clear();
} }
virtual void ClearActive() virtual void ClearActive()
{ {
dlc->Clear(Active.GetData(),Active.GetCount()); dlc->Clear(Active.GetData(),Active.GetCount());
Active.ClearData(); Active.Clear();
} }
virtual void ClearIdle() ///<清除所有非活跃数据 virtual void ClearIdle() ///<清除所有非活跃数据

View File

@ -121,8 +121,8 @@ namespace hgl
return total; return total;
} }
void Clear (){data_list.Clear();} ///<清除数据 void Free (){data_list.Free();} ///<清除数据,并释放内存
void ClearData (){data_list.ClearData();} ///<清除数据,但不释放内存 void Clear (){data_list.Clear();} ///<清除数据,但不释放内存
bool Get (const int index,T &data) ///<根据序列号取得指定数据 bool Get (const int index,T &data) ///<根据序列号取得指定数据
{ {

View File

@ -138,7 +138,7 @@ namespace hgl
/** /**
* *
*/ */
void Clear(){Items.ClearData();} ///<删除列表中的所有字符串 void Clear(){Items.Clear();} ///<删除列表中的所有字符串
/** /**
* *