diff --git a/inc/hgl/io/event/InputEvent.h b/inc/hgl/io/event/InputEvent.h index 8e37b0f..60dba15 100644 --- a/inc/hgl/io/event/InputEvent.h +++ b/inc/hgl/io/event/InputEvent.h @@ -1,7 +1,7 @@ #ifndef HGL_IO_INPUT_EVENT_INCLUDE #define HGL_IO_INPUT_EVENT_INCLUDE -#include +#include #include namespace hgl { @@ -31,7 +31,7 @@ namespace hgl InputEventSource source_type; - Sets sub_event_proc[size_t(InputEventSource::RANGE_SIZE)]; + SortedSets sub_event_proc[size_t(InputEventSource::RANGE_SIZE)]; public: diff --git a/inc/hgl/thread/Thread.h b/inc/hgl/thread/Thread.h index 8b42a99..5b91574 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: - Sets thread_set; + SortedSets thread_set; public: diff --git a/inc/hgl/type/Pool.h b/inc/hgl/type/Pool.h index 566515c..8914837 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/Sets.cpp b/inc/hgl/type/SortedSets.cpp similarity index 87% rename from inc/hgl/type/Sets.cpp rename to inc/hgl/type/SortedSets.cpp index 3c9044b..2922143 100644 --- a/inc/hgl/type/Sets.cpp +++ b/inc/hgl/type/SortedSets.cpp @@ -1,7 +1,7 @@ -#ifndef HGL_TYPE_SETS_CPP -#define HGL_TYPE_SETS_CPP +#ifndef HGL_TYPE_SORTED_SETS_CPP +#define HGL_TYPE_SORTED_SETS_CPP -#include +#include namespace hgl { /** @@ -10,7 +10,7 @@ namespace hgl * @return 数据所在索引,-1表示不存在 */ template - const int Sets::Find(const T &flag)const + const int SortedSets::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 Sets::FindPos(const T &flag,int &pos)const + bool SortedSets::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 Sets::Add(const T &data) + int SortedSets::Add(const T &data) { if(data_list.GetCount()<=0) { @@ -156,7 +156,7 @@ namespace hgl * @return 成功加入的数据个数 */ template - int Sets::Add(const T *dp,const int count) + int SortedSets::Add(const T *dp,const int count) { int total=0; @@ -177,7 +177,7 @@ namespace hgl * @return 是否成功 */ template - bool Sets::Update(const T &data) + bool SortedSets::Update(const T &data) { if(data_list.GetCount()<=0) return(false); @@ -196,7 +196,7 @@ namespace hgl * @param pos 索引编号 */ template - bool Sets::DeleteBySerial(int pos) + bool SortedSets::DeleteBySerial(int pos) { if(pos<0||pos>=data_list.GetCount())return(false); @@ -208,7 +208,7 @@ namespace hgl * @param data 数据 */ template - bool Sets::Delete(const T &data) + bool SortedSets::Delete(const T &data) { int pos=Find(data); @@ -224,7 +224,7 @@ namespace hgl * @return 成功删除的数据个数 */ template - int Sets::Delete(T *dp,const int count) + int SortedSets::Delete(T *dp,const int count) { int total=0; int pos; @@ -248,7 +248,7 @@ namespace hgl * 清除所有数据 */ template - void Sets::Clear() + void SortedSets::Clear() { data_list.Clear(); } @@ -257,7 +257,7 @@ namespace hgl * 清除所有数据,但不释放内存 */ template - void Sets::ClearData() + void SortedSets::ClearData() { data_list.ClearData(); } @@ -266,7 +266,7 @@ namespace hgl * 随机取得一个数据 */ template - bool Sets::Rand(T &result)const + bool SortedSets::Rand(T &result)const { return data_list.Rand(result); } @@ -278,7 +278,7 @@ namespace hgl * @return 交集数量 */ template - int Sets::Intersection(Sets &result,const Sets &list) + int SortedSets::Intersection(SortedSets &result,const SortedSets &list) { if(data_list.GetCount()<=0) return(0); @@ -296,7 +296,7 @@ namespace hgl } template - int Sets::Intersection(const Sets &list) + int SortedSets::Intersection(const SortedSets &list) { if(data_list.GetCount()<=0) return(0); @@ -319,7 +319,7 @@ namespace hgl } template - int Sets::Intersection(Sets &result,const Sets &il,const Sets &cl) + int SortedSets::Intersection(SortedSets &result,const SortedSets &il,const SortedSets &cl) { if(data_list.GetCount()<=0) return(0); @@ -340,7 +340,7 @@ namespace hgl } template - int Sets::Difference(const Sets &is) + int SortedSets::Difference(const SortedSets &is) { if(data_list.GetCount()<=0) return(is.GetCount()); @@ -362,4 +362,4 @@ namespace hgl return count; } }//namespace hgl -#endif//HGL_TYPE_SETS_CPP +#endif//HGL_TYPE_SORTED_SETS_CPP diff --git a/inc/hgl/type/Sets.h b/inc/hgl/type/SortedSets.h similarity index 76% rename from inc/hgl/type/Sets.h rename to inc/hgl/type/SortedSets.h index c8570f1..8761e73 100644 --- a/inc/hgl/type/Sets.h +++ b/inc/hgl/type/SortedSets.h @@ -1,13 +1,14 @@ -#ifndef HGL_TYPE_SETS_INCLUDE -#define HGL_TYPE_SETS_INCLUDE +#ifndef HGL_TYPE_SORTED_SETS_INCLUDE +#define HGL_TYPE_SORTED_SETS_INCLUDE #include namespace hgl { /** - * 集合数据列表中不允许数据出现重复性,同时它会将数据排序,所以也可以当做有序列表使用 - */ - template class Sets + * 有序合集
+ * 集合数据列表中不允许数据出现重复性,同时它会将数据排序 + */ + template class SortedSets { protected: @@ -27,8 +28,8 @@ namespace hgl public: - Sets()=default; - virtual ~Sets()=default; + SortedSets()=default; + virtual ~SortedSets()=default; void SetCount (int count){data_list.SetCount(count);} ///<指定数据数量,一般用于批量加载前的处理 void PreMalloc (int count){data_list.PreMalloc(count);} ///<预分配指定数量的数据空间 @@ -37,7 +38,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 Sets &s){return Add(s.GetData(),s.GetCount());} ///<添加一批数据 + int Add (const SortedSets &s){return Add(s.GetData(),s.GetCount());} ///<添加一批数据 bool Update (const T &); ///<更新一个数据 bool Delete (const T &); ///<删除一个数据 int Delete (T *,const int); ///<删除一批数据 @@ -58,8 +59,8 @@ namespace hgl bool GetBegin (T &data){return data_list.Begin(data);} ///<取得最前面一个数据 bool GetEnd (T &data){return data_list.End(data);} ///<取得最后面一个数据 - int Intersection (Sets &result,const Sets &set); ///<取得与指定合集的交集 - int Intersection (const Sets &set); ///<取得与指定合集的交集数量 + int Intersection (SortedSets &result,const SortedSets &set); ///<取得与指定合集的交集 + int Intersection (const SortedSets &set); ///<取得与指定合集的交集数量 /** * 取得与指定交集is的合集,但排斥cs合集中的数据 @@ -68,16 +69,16 @@ namespace hgl * @param cs 求排斥的合集 * @return 结果数量 */ - int Intersection (Sets &result,const Sets &is,const Sets &cs); + int Intersection (SortedSets &result,const SortedSets &is,const SortedSets &cs); - int Difference (const Sets &is); ///<求差集数量 + int Difference (const SortedSets &is); ///<求差集数量 - void operator =(const Sets &set){data_list=set.data_list;} ///<等号操作符重载 + void operator =(const SortedSets &set){data_list=set.data_list;} ///<等号操作符重载 bool Rand (T &)const; ///<随机取得一个 virtual void Enum (void (*enum_func)(T &)){data_list.Enum(enum_func);} ///<枚举所有数据成员 - };//template class Sets + };//template class SortedSets }//namespace hgl -#include -#endif//HGL_TYPE_SETS_INCLUDE +#include +#endif//HGL_TYPE_SORTED_SETS_INCLUDE