From d286de5b68bc6903aa467890f453381e861b8348 Mon Sep 17 00:00:00 2001 From: hyzboy Date: Mon, 30 Sep 2024 23:28:55 +0800 Subject: [PATCH] use Contains instead of IsMember/IsExist --- inc/hgl/type/Collection.h | 4 ++-- inc/hgl/type/ConstStringSet.h | 6 +++++- inc/hgl/type/DataArray.h | 12 ++++++------ inc/hgl/type/List.h | 2 +- inc/hgl/type/Map.cpp | 4 ++-- inc/hgl/type/Map.h | 4 ++-- inc/hgl/type/ObjectList.h | 2 +- inc/hgl/type/ObjectManage.h | 4 ++-- inc/hgl/type/Pool.h | 4 ++-- inc/hgl/type/Queue.h | 2 +- inc/hgl/type/RefObjectPool.h | 16 ++++++++-------- inc/hgl/type/SortedSets.h | 2 +- src/Log/Loginfo.cpp | 2 +- src/Type/DataChain.cpp | 2 +- 14 files changed, 35 insertions(+), 31 deletions(-) diff --git a/inc/hgl/type/Collection.h b/inc/hgl/type/Collection.h index 4b3fd42..7719006 100644 --- a/inc/hgl/type/Collection.h +++ b/inc/hgl/type/Collection.h @@ -145,10 +145,10 @@ namespace hgl return indexOfCondition(&cee); } - virtual bool isMember(const void *value) const{return indexOf(value)!=-1;} ///<判断当前数据是否是其成员 + virtual bool Contains(const void *value) const{return indexOf(value)!=-1;} ///<判断当前数据是否是其成员 template - bool isMemberValue(const T &value)const{return indexOf(value)!=-1;} ///<判断当前数据是否是其成员 + bool ContainsValue(const T &value)const{return indexOf(value)!=-1;} ///<判断当前数据是否是其成员 virtual int64 RemoveCondition(CheckElement *condition,int max_count=1); ///<按条件移除 diff --git a/inc/hgl/type/ConstStringSet.h b/inc/hgl/type/ConstStringSet.h index b35c44a..89310ea 100644 --- a/inc/hgl/type/ConstStringSet.h +++ b/inc/hgl/type/ConstStringSet.h @@ -91,7 +91,7 @@ namespace hgl public: - const bool IsMember(const SC *str,int length)const ///<判断字符串是否为合集成员 + const bool Contains(const SC *str,int length)const ///<判断字符串是否为合集成员 { if(!str||!*str||length<=0)return(-1); @@ -154,7 +154,11 @@ namespace hgl csv.id=GetID(str,length); if(csv.id>=0) + { + str_list.Get(csv.id,csv); + return csv.id; + } csv.str_data=&str_data; csv.id =str_set.GetCount(); diff --git a/inc/hgl/type/DataArray.h b/inc/hgl/type/DataArray.h index e2fb147..c51d48a 100644 --- a/inc/hgl/type/DataArray.h +++ b/inc/hgl/type/DataArray.h @@ -615,7 +615,7 @@ namespace hgl for(const T *sp:*this) { - if(!without_list.IsExist(*sp)) + if(!without_list.Contains(*sp)) { *p=*sp; ++p; @@ -656,7 +656,7 @@ namespace hgl // data_list.Enum([&](T &obj) // { - // if(list->IsMember(obj)) + // if(list->Contains(obj)) // result.Add(obj); // }); @@ -676,7 +676,7 @@ namespace hgl // T *obj=data_list.GetData(); // for(int64 i=0;i=0;} ///<确认数据项是否存在 + virtual bool Contains(const T &flag)const{return Find(flag)>=0;} ///<确认数据项是否存在 virtual bool Delete(int start,int num=1){return data_array.Delete(start,num);} ///<删除指定索引的数据 virtual bool DeleteMove(int start,int num=1){return data_array.DeleteMove(start,num);} ///<删除指定索引的数据,将后面紧邻的数据前移 diff --git a/inc/hgl/type/Map.cpp b/inc/hgl/type/Map.cpp index 23e5acf..4177292 100644 --- a/inc/hgl/type/Map.cpp +++ b/inc/hgl/type/Map.cpp @@ -618,7 +618,7 @@ namespace hgl for(int i=0;i::Clear(); } - virtual bool IsExist(const ItemPointer &flag)const override ///<确认数据项是否存在 + virtual bool Contains(const ItemPointer &flag)const override ///<确认数据项是否存在 { return List::Find((T *)flag)!=-1; } diff --git a/inc/hgl/type/ObjectManage.h b/inc/hgl/type/ObjectManage.h index b236639..6542cea 100644 --- a/inc/hgl/type/ObjectManage.h +++ b/inc/hgl/type/ObjectManage.h @@ -90,7 +90,7 @@ namespace hgl { if(!obj)return(false); - if(items.KeyExist(key)) + if(items.ContainsKey(key)) return(false); items.Add(key,obj); @@ -125,7 +125,7 @@ namespace hgl return(nullptr); } - virtual bool ValueExist(V *value) ///<确认这个对象是否存在 + virtual bool ContainsValue(V *value) ///<确认这个对象是否存在 { return(items.FindByValue(value)!=-1); } diff --git a/inc/hgl/type/Pool.h b/inc/hgl/type/Pool.h index 858285d..12da0b8 100644 --- a/inc/hgl/type/Pool.h +++ b/inc/hgl/type/Pool.h @@ -40,8 +40,8 @@ namespace hgl DataArray & GetActiveArray(){return Active.GetArray();} ///<取得所有活跃数据 - bool IsActive (const T &data)const{return Active.IsExist(data);} ///<是否为活跃的 - bool IsIdle (const T &data)const{return Idle.IsExist(data);} ///<是否为非活跃的 + bool IsActive (const T &data)const{return Active.Contains(data);} ///<是否为活跃的 + bool IsIdle (const T &data)const{return Idle.Contains(data);} ///<是否为非活跃的 bool IsFull()const ///<活跃队列是否已满 { diff --git a/inc/hgl/type/Queue.h b/inc/hgl/type/Queue.h index 3f763d4..b64007a 100644 --- a/inc/hgl/type/Queue.h +++ b/inc/hgl/type/Queue.h @@ -54,7 +54,7 @@ namespace hgl const bool IsEmpty ()const{return GetCount()==0;} ///<确认列表是否为空 - const bool IsExist (const T &data)const + const bool Contains (const T &data)const { if(data_array[read_index].Find(data,read_offset)!=-1) return(true); diff --git a/inc/hgl/type/RefObjectPool.h b/inc/hgl/type/RefObjectPool.h index 75eeb99..2a38055 100644 --- a/inc/hgl/type/RefObjectPool.h +++ b/inc/hgl/type/RefObjectPool.h @@ -57,10 +57,10 @@ namespace hgl const K *kp=key_list; for(int i=0;iref_count; - if(idle_items.KeyExist(key)) + if(idle_items.ContainsKey(key)) return 0; return -1; diff --git a/inc/hgl/type/SortedSets.h b/inc/hgl/type/SortedSets.h index d9f089e..24d35d0 100644 --- a/inc/hgl/type/SortedSets.h +++ b/inc/hgl/type/SortedSets.h @@ -54,7 +54,7 @@ namespace hgl return FindDataPositionInSortedArray(data_list,flag); } - bool IsMember (const T &v)const{return(Find(v)!=-1);} ///<确认是否成员 + bool Contains (const T &v)const{return(Find(v)!=-1);} ///<确认是否成员 /** * 添加一个数据 diff --git a/src/Log/Loginfo.cpp b/src/Log/Loginfo.cpp index 87a313c..e78ea79 100644 --- a/src/Log/Loginfo.cpp +++ b/src/Log/Loginfo.cpp @@ -18,7 +18,7 @@ namespace hgl OnlyWriteLock owl(log_list); - if(log_list->IsExist(log)) //重复添加 + if(log_list->Contains(log)) //重复添加 return(false); log_list->Add(log); diff --git a/src/Type/DataChain.cpp b/src/Type/DataChain.cpp index 549c2a2..79cf99e 100644 --- a/src/Type/DataChain.cpp +++ b/src/Type/DataChain.cpp @@ -119,7 +119,7 @@ namespace hgl if(!ud) return(false); - if(!ud_set.IsMember(ud)) + if(!ud_set.Contains(ud)) return(false); const int ud_end=ud->GetEnd();