map增加Check函数
This commit is contained in:
parent
19034291b2
commit
4ca69c06f5
@ -218,6 +218,19 @@ namespace hgl
|
||||
return(true);
|
||||
}
|
||||
|
||||
template<typename F,typename T,typename DataPair>
|
||||
bool _Map<F,T,DataPair>::Check(const F &key,const T &value) const
|
||||
{
|
||||
int index=Find(key);
|
||||
|
||||
DataPair *obj=GetObject(data_list,index);
|
||||
|
||||
if(!obj)
|
||||
return(false);
|
||||
|
||||
return (value==obj->right);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据序号取得数据
|
||||
* @param index 序号
|
||||
|
@ -39,6 +39,7 @@ namespace hgl
|
||||
int FindByValue(const T &)const; ///<查找数据是否存在,返回-1表示数据不存在
|
||||
bool KeyExist(const F &key)const{return(Find(key)!=-1);} ///<确认这个数据是否存在
|
||||
bool ValueExist(const T &value)const{return(FindByValue(value)!=-1);} ///<确认这个数据是否存在
|
||||
bool Check(const F &key,const T &value)const; ///<确认数据是否是这个
|
||||
virtual bool Get(const F &,T &)const; ///<取得数据
|
||||
virtual bool Delete(const F &,T &); ///<将指定数据从列表中移除,并获得这个数据
|
||||
virtual bool DeleteByKey(const F &); ///<根据索引将指定数据从列表中移除
|
||||
|
Loading…
x
Reference in New Issue
Block a user