rename from Set<> to Sets<>

This commit is contained in:
hyzboy 2020-09-21 11:53:52 +08:00
parent 25a2605932
commit d36b64cdb5
4 changed files with 36 additions and 36 deletions

View File

@ -2,7 +2,7 @@
#define HGL_THREAD_INCLUDE #define HGL_THREAD_INCLUDE
#include<hgl/type/DataType.h> #include<hgl/type/DataType.h>
#include<hgl/type/Set.h> #include<hgl/type/Sets.h>
#include<hgl/type/String.h> #include<hgl/type/String.h>
#include<hgl/thread/ThreadMutex.h> #include<hgl/thread/ThreadMutex.h>
#include<hgl/log/LogInfo.h> #include<hgl/log/LogInfo.h>
@ -123,7 +123,7 @@ namespace hgl
{ {
protected: protected:
Set<THREAD *> thread_set; Sets<THREAD *> thread_set;
public: public:

View File

@ -5,7 +5,7 @@
#include<hgl/type/Queue.h> #include<hgl/type/Queue.h>
#include<hgl/thread/RWLock.h> #include<hgl/thread/RWLock.h>
#include<hgl/thread/ThreadMutex.h> #include<hgl/thread/ThreadMutex.h>
#include<hgl/type/Set.h> #include<hgl/type/Sets.h>
namespace hgl namespace hgl
{ {
/** /**

View File

@ -1,7 +1,7 @@
#ifndef HGL_TYPE_SET_CPP #ifndef HGL_TYPE_SETS_CPP
#define HGL_TYPE_SET_CPP #define HGL_TYPE_SETS_CPP
#include<hgl/type/Set.h> #include<hgl/type/Sets.h>
namespace hgl namespace hgl
{ {
/** /**
@ -10,7 +10,7 @@ namespace hgl
* @return -1 * @return -1
*/ */
template<typename T> template<typename T>
const int Set<T>::Find(const T &flag)const const int Sets<T>::Find(const T &flag)const
{ {
int left=0,right=data_list.GetCount()-1; //使用left,right而不使用min,max是为了让代码能够更好的阅读。 int left=0,right=data_list.GetCount()-1; //使用left,right而不使用min,max是为了让代码能够更好的阅读。
int mid; int mid;
@ -42,7 +42,7 @@ namespace hgl
} }
template<typename T> template<typename T>
bool Set<T>::FindPos(const T &flag,int &pos)const bool Sets<T>::FindPos(const T &flag,int &pos)const
{ {
int left=0,right=data_list.GetCount()-1; int left=0,right=data_list.GetCount()-1;
int mid; int mid;
@ -128,7 +128,7 @@ namespace hgl
* @return * @return
*/ */
template<typename T> template<typename T>
int Set<T>::Add(const T &data) int Sets<T>::Add(const T &data)
{ {
if(data_list.GetCount()<=0) if(data_list.GetCount()<=0)
{ {
@ -156,7 +156,7 @@ namespace hgl
* @return * @return
*/ */
template<typename T> template<typename T>
int Set<T>::Add(const T *dp,const int count) int Sets<T>::Add(const T *dp,const int count)
{ {
int total=0; int total=0;
@ -177,7 +177,7 @@ namespace hgl
* @return * @return
*/ */
template<typename T> template<typename T>
bool Set<T>::Update(const T &data) bool Sets<T>::Update(const T &data)
{ {
if(data_list.GetCount()<=0) if(data_list.GetCount()<=0)
return(false); return(false);
@ -196,7 +196,7 @@ namespace hgl
* @param pos * @param pos
*/ */
template<typename T> template<typename T>
bool Set<T>::DeleteBySerial(int pos) bool Sets<T>::DeleteBySerial(int pos)
{ {
if(pos<0||pos>=data_list.GetCount())return(false); if(pos<0||pos>=data_list.GetCount())return(false);
@ -208,7 +208,7 @@ namespace hgl
* @param data * @param data
*/ */
template<typename T> template<typename T>
bool Set<T>::Delete(const T &data) bool Sets<T>::Delete(const T &data)
{ {
int pos=Find(data); int pos=Find(data);
@ -224,7 +224,7 @@ namespace hgl
* @return * @return
*/ */
template<typename T> template<typename T>
int Set<T>::Delete(T *dp,const int count) int Sets<T>::Delete(T *dp,const int count)
{ {
int total=0; int total=0;
int pos; int pos;
@ -248,7 +248,7 @@ namespace hgl
* *
*/ */
template<typename T> template<typename T>
void Set<T>::Clear() void Sets<T>::Clear()
{ {
data_list.Clear(); data_list.Clear();
} }
@ -257,7 +257,7 @@ namespace hgl
* *
*/ */
template<typename T> template<typename T>
void Set<T>::ClearData() void Sets<T>::ClearData()
{ {
data_list.ClearData(); data_list.ClearData();
} }
@ -266,7 +266,7 @@ namespace hgl
* *
*/ */
template<typename T> template<typename T>
bool Set<T>::Rand(T &result)const bool Sets<T>::Rand(T &result)const
{ {
return data_list.Rand(result); return data_list.Rand(result);
} }
@ -278,7 +278,7 @@ namespace hgl
* @return * @return
*/ */
template<typename T> template<typename T>
int Set<T>::Intersection(Set<T> &result,const Set<T> &list) int Sets<T>::Intersection(Sets<T> &result,const Sets<T> &list)
{ {
if(data_list.GetCount()<=0) if(data_list.GetCount()<=0)
return(0); return(0);
@ -296,7 +296,7 @@ namespace hgl
} }
template<typename T> template<typename T>
int Set<T>::Intersection(const Set<T> &list) int Sets<T>::Intersection(const Sets<T> &list)
{ {
if(data_list.GetCount()<=0) if(data_list.GetCount()<=0)
return(0); return(0);
@ -319,7 +319,7 @@ namespace hgl
} }
template<typename T> template<typename T>
int Set<T>::Intersection(Set<T> &result,const Set<T> &il,const Set<T> &cl) int Sets<T>::Intersection(Sets<T> &result,const Sets<T> &il,const Sets<T> &cl)
{ {
if(data_list.GetCount()<=0) if(data_list.GetCount()<=0)
return(0); return(0);
@ -340,7 +340,7 @@ namespace hgl
} }
template<typename T> template<typename T>
int Set<T>::Difference(const Set<T> &is) int Sets<T>::Difference(const Sets<T> &is)
{ {
if(data_list.GetCount()<=0) if(data_list.GetCount()<=0)
return(is.GetCount()); return(is.GetCount());
@ -362,4 +362,4 @@ namespace hgl
return count; return count;
} }
}//namespace hgl }//namespace hgl
#endif//HGL_TYPE_SET_CPP #endif//HGL_TYPE_SETS_CPP

View File

@ -1,5 +1,5 @@
#ifndef HGL_TYPE_SET_INCLUDE #ifndef HGL_TYPE_SETS_INCLUDE
#define HGL_TYPE_SET_INCLUDE #define HGL_TYPE_SETS_INCLUDE
#include<hgl/type/List.h> #include<hgl/type/List.h>
namespace hgl namespace hgl
@ -7,7 +7,7 @@ namespace hgl
/** /**
* 使 * 使
*/ */
template<typename T> class Set template<typename T> class Sets
{ {
protected: protected:
@ -24,8 +24,8 @@ namespace hgl
public: public:
Set()=default; Sets()=default;
virtual ~Set()=default; virtual ~Sets()=default;
void SetCount (int count){data_list.SetCount(count);} ///<指定数据数量,一般用于批量加载前的处理 void SetCount (int count){data_list.SetCount(count);} ///<指定数据数量,一般用于批量加载前的处理
void PreMalloc (int count){data_list.PreMalloc(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);} ///<确认是否成员 const bool IsMember (const T &v)const{return(Find(v)!=-1);} ///<确认是否成员
int Add (const T &); ///<添加一个数据,返回索引号,返回-1表示数据已存在 int Add (const T &); ///<添加一个数据,返回索引号,返回-1表示数据已存在
int Add (const T *,const int); ///<添加一批数据 int Add (const T *,const int); ///<添加一批数据
int Add (const Set<T> &s){return Add(s.GetData(),s.GetCount());} ///<添加一批数据 int Add (const Sets<T> &s){return Add(s.GetData(),s.GetCount());} ///<添加一批数据
bool Update (const T &); ///<更新一个数据 bool Update (const T &); ///<更新一个数据
bool Delete (const T &); ///<删除一个数据 bool Delete (const T &); ///<删除一个数据
int Delete (T *,const int); ///<删除一批数据 int Delete (T *,const int); ///<删除一批数据
@ -55,8 +55,8 @@ namespace hgl
bool GetBegin (T &data){return data_list.Begin(data);} ///<取得最前面一个数据 bool GetBegin (T &data){return data_list.Begin(data);} ///<取得最前面一个数据
bool GetEnd (T &data){return data_list.End(data);} ///<取得最后面一个数据 bool GetEnd (T &data){return data_list.End(data);} ///<取得最后面一个数据
int Intersection (Set<T> &result,const Set<T> &set); ///<取得与指定合集的交集 int Intersection (Sets<T> &result,const Sets<T> &set); ///<取得与指定合集的交集
int Intersection (const Set<T> &set); ///<取得与指定合集的交集数量 int Intersection (const Sets<T> &set); ///<取得与指定合集的交集数量
/** /**
* is的合集cs合集中的数据 * is的合集cs合集中的数据
@ -65,16 +65,16 @@ namespace hgl
* @param cs * @param cs
* @return * @return
*/ */
int Intersection (Set<T> &result,const Set<T> &is,const Set<T> &cs); int Intersection (Sets<T> &result,const Sets<T> &is,const Sets<T> &cs);
int Difference (const Set<T> &is); ///<求差集数量 int Difference (const Sets<T> &is); ///<求差集数量
void operator =(const Set<T> &set){data_list=set.data_list;} ///<等号操作符重载 void operator =(const Sets<T> &set){data_list=set.data_list;} ///<等号操作符重载
bool Rand (T &)const; ///<随机取得一个 bool Rand (T &)const; ///<随机取得一个
virtual void Enum (void (*enum_func)(T &)){data_list.Enum(enum_func);} ///<枚举所有数据成员 virtual void Enum (void (*enum_func)(T &)){data_list.Enum(enum_func);} ///<枚举所有数据成员
};//template<typename T> class Set };//template<typename T> class Sets
}//namespace hgl }//namespace hgl
#include<hgl/type/Set.cpp> #include<hgl/type/Sets.cpp>
#endif//HGL_TYPE_SET_INCLUDE #endif//HGL_TYPE_SETS_INCLUDE