use Contains instead of IsMember/IsExist
This commit is contained in:
parent
0a2ca9272e
commit
d286de5b68
@ -145,10 +145,10 @@ namespace hgl
|
|||||||
return indexOfCondition(&cee);
|
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<typename T>
|
template<typename T>
|
||||||
bool isMemberValue(const T &value)const{return indexOf<T>(value)!=-1;} ///<判断当前数据是否是其成员
|
bool ContainsValue(const T &value)const{return indexOf<T>(value)!=-1;} ///<判断当前数据是否是其成员
|
||||||
|
|
||||||
virtual int64 RemoveCondition(CheckElement *condition,int max_count=1); ///<按条件移除
|
virtual int64 RemoveCondition(CheckElement *condition,int max_count=1); ///<按条件移除
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ namespace hgl
|
|||||||
|
|
||||||
public:
|
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);
|
if(!str||!*str||length<=0)return(-1);
|
||||||
|
|
||||||
@ -154,7 +154,11 @@ namespace hgl
|
|||||||
csv.id=GetID(str,length);
|
csv.id=GetID(str,length);
|
||||||
|
|
||||||
if(csv.id>=0)
|
if(csv.id>=0)
|
||||||
|
{
|
||||||
|
str_list.Get(csv.id,csv);
|
||||||
|
|
||||||
return csv.id;
|
return csv.id;
|
||||||
|
}
|
||||||
|
|
||||||
csv.str_data=&str_data;
|
csv.str_data=&str_data;
|
||||||
csv.id =str_set.GetCount();
|
csv.id =str_set.GetCount();
|
||||||
|
@ -615,7 +615,7 @@ namespace hgl
|
|||||||
|
|
||||||
for(const T *sp:*this)
|
for(const T *sp:*this)
|
||||||
{
|
{
|
||||||
if(!without_list.IsExist(*sp))
|
if(!without_list.Contains(*sp))
|
||||||
{
|
{
|
||||||
*p=*sp;
|
*p=*sp;
|
||||||
++p;
|
++p;
|
||||||
@ -656,7 +656,7 @@ namespace hgl
|
|||||||
|
|
||||||
// data_list.Enum([&](T &obj)
|
// data_list.Enum([&](T &obj)
|
||||||
// {
|
// {
|
||||||
// if(list->IsMember(obj))
|
// if(list->Contains(obj))
|
||||||
// result.Add(obj);
|
// result.Add(obj);
|
||||||
// });
|
// });
|
||||||
|
|
||||||
@ -676,7 +676,7 @@ namespace hgl
|
|||||||
// T *obj=data_list.GetData();
|
// T *obj=data_list.GetData();
|
||||||
// for(int64 i=0;i<data_list.GetCount();i++)
|
// for(int64 i=0;i<data_list.GetCount();i++)
|
||||||
// {
|
// {
|
||||||
// if(list.IsMember(*obj))
|
// if(list.Contains(*obj))
|
||||||
// ++count;
|
// ++count;
|
||||||
|
|
||||||
// ++obj;
|
// ++obj;
|
||||||
@ -696,8 +696,8 @@ namespace hgl
|
|||||||
// T *obj=data_list.GetData();
|
// T *obj=data_list.GetData();
|
||||||
// for(int64 i=0;i<data_list.GetCount();i++)
|
// for(int64 i=0;i<data_list.GetCount();i++)
|
||||||
// {
|
// {
|
||||||
// if(il.IsMember(*obj))
|
// if(il.Contains(*obj))
|
||||||
// if(!cl.IsMember(*obj))
|
// if(!cl.Contains(*obj))
|
||||||
// result.Add(*obj);
|
// result.Add(*obj);
|
||||||
// ++obj;
|
// ++obj;
|
||||||
// }
|
// }
|
||||||
@ -718,7 +718,7 @@ namespace hgl
|
|||||||
// T *obj=data_list.GetData();
|
// T *obj=data_list.GetData();
|
||||||
// for(int64 i=0;i<data_list.GetCount();i++)
|
// for(int64 i=0;i<data_list.GetCount();i++)
|
||||||
// {
|
// {
|
||||||
// if(!is.IsMember(*obj))
|
// if(!is.Contains(*obj))
|
||||||
// ++count;
|
// ++count;
|
||||||
|
|
||||||
// ++obj;
|
// ++obj;
|
||||||
|
@ -119,7 +119,7 @@ namespace hgl
|
|||||||
virtual void Clear(){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 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 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);} ///<删除指定索引的数据,将后面紧邻的数据前移
|
virtual bool DeleteMove(int start,int num=1){return data_array.DeleteMove(start,num);} ///<删除指定索引的数据,将后面紧邻的数据前移
|
||||||
|
@ -618,7 +618,7 @@ namespace hgl
|
|||||||
|
|
||||||
for(int i=0;i<count;i++)
|
for(int i=0;i<count;i++)
|
||||||
{
|
{
|
||||||
if(in_list.IsExist(*sp))
|
if(in_list.Contains(*sp))
|
||||||
with_list.Add(*sp);
|
with_list.Add(*sp);
|
||||||
|
|
||||||
++sp;
|
++sp;
|
||||||
@ -642,7 +642,7 @@ namespace hgl
|
|||||||
|
|
||||||
for(int i=0;i<count;i++)
|
for(int i=0;i<count;i++)
|
||||||
{
|
{
|
||||||
if(!in_list.IsExist(*sp))
|
if(!in_list.Contains(*sp))
|
||||||
without_list.Add(*sp);
|
without_list.Add(*sp);
|
||||||
|
|
||||||
++sp;
|
++sp;
|
||||||
|
@ -47,8 +47,8 @@ namespace hgl
|
|||||||
int FindPos(const K &flag)const{int pos;FindPos(flag,pos);return(pos);} ///<查找数据如果插入后,会所在的位置
|
int FindPos(const K &flag)const{int pos;FindPos(flag,pos);return(pos);} ///<查找数据如果插入后,会所在的位置
|
||||||
int Find(const K &)const; ///<查找数据是否存在,返回-1表示数据不存在
|
int Find(const K &)const; ///<查找数据是否存在,返回-1表示数据不存在
|
||||||
int FindByValue(const V &)const; ///<查找数据是否存在,返回-1表示数据不存在
|
int FindByValue(const V &)const; ///<查找数据是否存在,返回-1表示数据不存在
|
||||||
bool KeyExist(const K &key)const{return(Find(key)!=-1);} ///<确认这个数据是否存在
|
bool ContainsKey(const K &key)const{return(Find(key)!=-1);} ///<确认这个数据是否存在
|
||||||
bool ValueExist(const V &value)const{return(FindByValue(value)!=-1);} ///<确认这个数据是否存在
|
bool ContainsValue(const V &value)const{return(FindByValue(value)!=-1);} ///<确认这个数据是否存在
|
||||||
bool Check(const K &key,const V &value)const; ///<确认数据是否是这个
|
bool Check(const K &key,const V &value)const; ///<确认数据是否是这个
|
||||||
virtual V * GetPointer(const K &key)const; ///<取得数据指针
|
virtual V * GetPointer(const K &key)const; ///<取得数据指针
|
||||||
virtual int GetValueAndSerial(const K &,V &) const; ///<取得数据与索引
|
virtual int GetValueAndSerial(const K &,V &) const; ///<取得数据与索引
|
||||||
|
@ -44,7 +44,7 @@ namespace hgl
|
|||||||
List<T *>::Clear();
|
List<T *>::Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool IsExist(const ItemPointer &flag)const override ///<确认数据项是否存在
|
virtual bool Contains(const ItemPointer &flag)const override ///<确认数据项是否存在
|
||||||
{
|
{
|
||||||
return List<T *>::Find((T *)flag)!=-1;
|
return List<T *>::Find((T *)flag)!=-1;
|
||||||
}
|
}
|
||||||
|
@ -90,7 +90,7 @@ namespace hgl
|
|||||||
{
|
{
|
||||||
if(!obj)return(false);
|
if(!obj)return(false);
|
||||||
|
|
||||||
if(items.KeyExist(key))
|
if(items.ContainsKey(key))
|
||||||
return(false);
|
return(false);
|
||||||
|
|
||||||
items.Add(key,obj);
|
items.Add(key,obj);
|
||||||
@ -125,7 +125,7 @@ namespace hgl
|
|||||||
return(nullptr);
|
return(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool ValueExist(V *value) ///<确认这个对象是否存在
|
virtual bool ContainsValue(V *value) ///<确认这个对象是否存在
|
||||||
{
|
{
|
||||||
return(items.FindByValue(value)!=-1);
|
return(items.FindByValue(value)!=-1);
|
||||||
}
|
}
|
||||||
|
@ -40,8 +40,8 @@ namespace hgl
|
|||||||
|
|
||||||
DataArray<T> & GetActiveArray(){return Active.GetArray();} ///<取得所有活跃数据
|
DataArray<T> & GetActiveArray(){return Active.GetArray();} ///<取得所有活跃数据
|
||||||
|
|
||||||
bool IsActive (const T &data)const{return Active.IsExist(data);} ///<是否为活跃的
|
bool IsActive (const T &data)const{return Active.Contains(data);} ///<是否为活跃的
|
||||||
bool IsIdle (const T &data)const{return Idle.IsExist(data);} ///<是否为非活跃的
|
bool IsIdle (const T &data)const{return Idle.Contains(data);} ///<是否为非活跃的
|
||||||
|
|
||||||
bool IsFull()const ///<活跃队列是否已满
|
bool IsFull()const ///<活跃队列是否已满
|
||||||
{
|
{
|
||||||
|
@ -54,7 +54,7 @@ namespace hgl
|
|||||||
|
|
||||||
const bool IsEmpty ()const{return GetCount()==0;} ///<确认列表是否为空
|
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)
|
if(data_array[read_index].Find(data,read_offset)!=-1)
|
||||||
return(true);
|
return(true);
|
||||||
|
@ -57,10 +57,10 @@ namespace hgl
|
|||||||
const K *kp=key_list;
|
const K *kp=key_list;
|
||||||
for(int i=0;i<key_count;i++)
|
for(int i=0;i<key_count;i++)
|
||||||
{
|
{
|
||||||
if(active_items.KeyExist(*kp))
|
if(active_items.ContainsKey(*kp))
|
||||||
++(stats.active);
|
++(stats.active);
|
||||||
else
|
else
|
||||||
if(idle_items.KeyExist(*kp))
|
if(idle_items.ContainsKey(*kp))
|
||||||
++(stats.idle);
|
++(stats.idle);
|
||||||
else
|
else
|
||||||
++(stats.not_found);
|
++(stats.not_found);
|
||||||
@ -74,22 +74,22 @@ namespace hgl
|
|||||||
/**
|
/**
|
||||||
* 确定指定key是否在活跃列表
|
* 确定指定key是否在活跃列表
|
||||||
*/
|
*/
|
||||||
bool KeyExistActive(const K &key)const{return active_items.KeyExist(key);}
|
bool KeyExistActive(const K &key)const{return active_items.ContainsKey(key);}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 确定指定key是否在闲置列表
|
* 确定指定key是否在闲置列表
|
||||||
*/
|
*/
|
||||||
bool KeyExistIdle(const K &key)const{return idle_items.KeyExist(key);}
|
bool KeyExistIdle(const K &key)const{return idle_items.ContainsKey(key);}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 确定指定key是否在列表中(包括活跃列表和闲置列表)
|
* 确定指定key是否在列表中(包括活跃列表和闲置列表)
|
||||||
*/
|
*/
|
||||||
bool KeyExist(const K &key)const
|
bool ContainsKey(const K &key)const
|
||||||
{
|
{
|
||||||
if(active_items.KeyExist(key))
|
if(active_items.ContainsKey(key))
|
||||||
return(true);
|
return(true);
|
||||||
|
|
||||||
if(idle_items.KeyExist(key))
|
if(idle_items.ContainsKey(key))
|
||||||
return(true);
|
return(true);
|
||||||
|
|
||||||
return(false);
|
return(false);
|
||||||
@ -109,7 +109,7 @@ namespace hgl
|
|||||||
if(active_items.Get(key,ai)) //在活跃列表中找
|
if(active_items.Get(key,ai)) //在活跃列表中找
|
||||||
return ai->ref_count;
|
return ai->ref_count;
|
||||||
|
|
||||||
if(idle_items.KeyExist(key))
|
if(idle_items.ContainsKey(key))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -54,7 +54,7 @@ namespace hgl
|
|||||||
return FindDataPositionInSortedArray(data_list,flag);
|
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);} ///<确认是否成员
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加一个数据
|
* 添加一个数据
|
||||||
|
@ -18,7 +18,7 @@ namespace hgl
|
|||||||
|
|
||||||
OnlyWriteLock owl(log_list);
|
OnlyWriteLock owl(log_list);
|
||||||
|
|
||||||
if(log_list->IsExist(log)) //重复添加
|
if(log_list->Contains(log)) //重复添加
|
||||||
return(false);
|
return(false);
|
||||||
|
|
||||||
log_list->Add(log);
|
log_list->Add(log);
|
||||||
|
@ -119,7 +119,7 @@ namespace hgl
|
|||||||
if(!ud)
|
if(!ud)
|
||||||
return(false);
|
return(false);
|
||||||
|
|
||||||
if(!ud_set.IsMember(ud))
|
if(!ud_set.Contains(ud))
|
||||||
return(false);
|
return(false);
|
||||||
|
|
||||||
const int ud_end=ud->GetEnd();
|
const int ud_end=ud->GetEnd();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user