From d36b64cdb5944b812f6edf8caf6f6033a1331910 Mon Sep 17 00:00:00 2001 From: hyzboy Date: Mon, 21 Sep 2020 11:53:52 +0800 Subject: [PATCH] rename from Set<> to Sets<> --- inc/hgl/thread/Thread.h | 4 ++-- inc/hgl/type/Pool.h | 2 +- inc/hgl/type/{Set.cpp => Sets.cpp} | 38 +++++++++++++++--------------- inc/hgl/type/{Set.h => Sets.h} | 28 +++++++++++----------- 4 files changed, 36 insertions(+), 36 deletions(-) rename inc/hgl/type/{Set.cpp => Sets.cpp} (89%) rename inc/hgl/type/{Set.h => Sets.h} (79%) diff --git a/inc/hgl/thread/Thread.h b/inc/hgl/thread/Thread.h index eeae8a8..8b42a99 100644 --- a/inc/hgl/thread/Thread.h +++ b/inc/hgl/thread/Thread.h @@ -2,7 +2,7 @@ #define HGL_THREAD_INCLUDE #include -#include +#include #include #include #include @@ -123,7 +123,7 @@ namespace hgl { protected: - Set thread_set; + Sets thread_set; public: diff --git a/inc/hgl/type/Pool.h b/inc/hgl/type/Pool.h index af190da..566515c 100644 --- a/inc/hgl/type/Pool.h +++ b/inc/hgl/type/Pool.h @@ -5,7 +5,7 @@ #include #include #include -#include +#include namespace hgl { /** diff --git a/inc/hgl/type/Set.cpp b/inc/hgl/type/Sets.cpp similarity index 89% rename from inc/hgl/type/Set.cpp rename to inc/hgl/type/Sets.cpp index 393a2a5..3c9044b 100644 --- a/inc/hgl/type/Set.cpp +++ b/inc/hgl/type/Sets.cpp @@ -1,7 +1,7 @@ -#ifndef HGL_TYPE_SET_CPP -#define HGL_TYPE_SET_CPP +#ifndef HGL_TYPE_SETS_CPP +#define HGL_TYPE_SETS_CPP -#include +#include namespace hgl { /** @@ -10,7 +10,7 @@ namespace hgl * @return 数据所在索引,-1表示不存在 */ template - const int Set::Find(const T &flag)const + const int Sets::Find(const T &flag)const { int left=0,right=data_list.GetCount()-1; //使用left,right而不使用min,max是为了让代码能够更好的阅读。 int mid; @@ -42,7 +42,7 @@ namespace hgl } template - bool Set::FindPos(const T &flag,int &pos)const + bool Sets::FindPos(const T &flag,int &pos)const { int left=0,right=data_list.GetCount()-1; int mid; @@ -128,7 +128,7 @@ namespace hgl * @return 位置 */ template - int Set::Add(const T &data) + int Sets::Add(const T &data) { if(data_list.GetCount()<=0) { @@ -156,7 +156,7 @@ namespace hgl * @return 成功加入的数据个数 */ template - int Set::Add(const T *dp,const int count) + int Sets::Add(const T *dp,const int count) { int total=0; @@ -177,7 +177,7 @@ namespace hgl * @return 是否成功 */ template - bool Set::Update(const T &data) + bool Sets::Update(const T &data) { if(data_list.GetCount()<=0) return(false); @@ -196,7 +196,7 @@ namespace hgl * @param pos 索引编号 */ template - bool Set::DeleteBySerial(int pos) + bool Sets::DeleteBySerial(int pos) { if(pos<0||pos>=data_list.GetCount())return(false); @@ -208,7 +208,7 @@ namespace hgl * @param data 数据 */ template - bool Set::Delete(const T &data) + bool Sets::Delete(const T &data) { int pos=Find(data); @@ -224,7 +224,7 @@ namespace hgl * @return 成功删除的数据个数 */ template - int Set::Delete(T *dp,const int count) + int Sets::Delete(T *dp,const int count) { int total=0; int pos; @@ -248,7 +248,7 @@ namespace hgl * 清除所有数据 */ template - void Set::Clear() + void Sets::Clear() { data_list.Clear(); } @@ -257,7 +257,7 @@ namespace hgl * 清除所有数据,但不释放内存 */ template - void Set::ClearData() + void Sets::ClearData() { data_list.ClearData(); } @@ -266,7 +266,7 @@ namespace hgl * 随机取得一个数据 */ template - bool Set::Rand(T &result)const + bool Sets::Rand(T &result)const { return data_list.Rand(result); } @@ -278,7 +278,7 @@ namespace hgl * @return 交集数量 */ template - int Set::Intersection(Set &result,const Set &list) + int Sets::Intersection(Sets &result,const Sets &list) { if(data_list.GetCount()<=0) return(0); @@ -296,7 +296,7 @@ namespace hgl } template - int Set::Intersection(const Set &list) + int Sets::Intersection(const Sets &list) { if(data_list.GetCount()<=0) return(0); @@ -319,7 +319,7 @@ namespace hgl } template - int Set::Intersection(Set &result,const Set &il,const Set &cl) + int Sets::Intersection(Sets &result,const Sets &il,const Sets &cl) { if(data_list.GetCount()<=0) return(0); @@ -340,7 +340,7 @@ namespace hgl } template - int Set::Difference(const Set &is) + int Sets::Difference(const Sets &is) { if(data_list.GetCount()<=0) return(is.GetCount()); @@ -362,4 +362,4 @@ namespace hgl return count; } }//namespace hgl -#endif//HGL_TYPE_SET_CPP +#endif//HGL_TYPE_SETS_CPP diff --git a/inc/hgl/type/Set.h b/inc/hgl/type/Sets.h similarity index 79% rename from inc/hgl/type/Set.h rename to inc/hgl/type/Sets.h index cee2f57..7b16a66 100644 --- a/inc/hgl/type/Set.h +++ b/inc/hgl/type/Sets.h @@ -1,5 +1,5 @@ -#ifndef HGL_TYPE_SET_INCLUDE -#define HGL_TYPE_SET_INCLUDE +#ifndef HGL_TYPE_SETS_INCLUDE +#define HGL_TYPE_SETS_INCLUDE #include namespace hgl @@ -7,7 +7,7 @@ namespace hgl /** * 集合数据列表中不允许数据出现重复性,同时它会将数据排序,所以也可以当做有序列表使用 */ - template class Set + template class Sets { protected: @@ -24,8 +24,8 @@ namespace hgl public: - Set()=default; - virtual ~Set()=default; + Sets()=default; + virtual ~Sets()=default; void SetCount (int count){data_list.SetCount(count);} ///<指定数据数量,一般用于批量加载前的处理 void PreMalloc (int count){data_list.PreMalloc(count);} ///<预分配指定数量的数据空间 @@ -34,7 +34,7 @@ namespace hgl const bool IsMember (const T &v)const{return(Find(v)!=-1);} ///<确认是否成员 int Add (const T &); ///<添加一个数据,返回索引号,返回-1表示数据已存在 int Add (const T *,const int); ///<添加一批数据 - int Add (const Set &s){return Add(s.GetData(),s.GetCount());} ///<添加一批数据 + int Add (const Sets &s){return Add(s.GetData(),s.GetCount());} ///<添加一批数据 bool Update (const T &); ///<更新一个数据 bool Delete (const T &); ///<删除一个数据 int Delete (T *,const int); ///<删除一批数据 @@ -55,8 +55,8 @@ namespace hgl bool GetBegin (T &data){return data_list.Begin(data);} ///<取得最前面一个数据 bool GetEnd (T &data){return data_list.End(data);} ///<取得最后面一个数据 - int Intersection (Set &result,const Set &set); ///<取得与指定合集的交集 - int Intersection (const Set &set); ///<取得与指定合集的交集数量 + int Intersection (Sets &result,const Sets &set); ///<取得与指定合集的交集 + int Intersection (const Sets &set); ///<取得与指定合集的交集数量 /** * 取得与指定交集is的合集,但排斥cs合集中的数据 @@ -65,16 +65,16 @@ namespace hgl * @param cs 求排斥的合集 * @return 结果数量 */ - int Intersection (Set &result,const Set &is,const Set &cs); + int Intersection (Sets &result,const Sets &is,const Sets &cs); - int Difference (const Set &is); ///<求差集数量 + int Difference (const Sets &is); ///<求差集数量 - void operator =(const Set &set){data_list=set.data_list;} ///<等号操作符重载 + void operator =(const Sets &set){data_list=set.data_list;} ///<等号操作符重载 bool Rand (T &)const; ///<随机取得一个 virtual void Enum (void (*enum_func)(T &)){data_list.Enum(enum_func);} ///<枚举所有数据成员 - };//template class Set + };//template class Sets }//namespace hgl -#include -#endif//HGL_TYPE_SET_INCLUDE +#include +#endif//HGL_TYPE_SETS_INCLUDE