map增加Check函数

This commit is contained in:
HuYingzhuo 2019-04-27 22:02:23 +08:00
parent 19034291b2
commit 4ca69c06f5
2 changed files with 14 additions and 0 deletions

View File

@ -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

View File

@ -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 &); ///<根据索引将指定数据从列表中移除