mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2025-01-31 09:57:14 +01:00
Add method to check for existence of an element.
This commit is contained in:
parent
323dc3ad1b
commit
8fc23a837a
@ -25,6 +25,7 @@ void Register_Dictionary(HSQUIRRELVM vm, Table & ns)
|
|||||||
.Func(_SC("Set"), &SqDictionary::Set)
|
.Func(_SC("Set"), &SqDictionary::Set)
|
||||||
.Func(_SC("Clear"), &SqDictionary::Clear)
|
.Func(_SC("Clear"), &SqDictionary::Clear)
|
||||||
.Func(_SC("Erase"), &SqDictionary::Erase)
|
.Func(_SC("Erase"), &SqDictionary::Erase)
|
||||||
|
.Func(_SC("Exists"), &SqDictionary::Exists)
|
||||||
.CbFunc(_SC("Each"), &SqDictionary::Each)
|
.CbFunc(_SC("Each"), &SqDictionary::Each)
|
||||||
.CbFunc(_SC("EachWith"), &SqDictionary::EachWith)
|
.CbFunc(_SC("EachWith"), &SqDictionary::EachWith)
|
||||||
.CbFunc(_SC("While"), &SqDictionary::While)
|
.CbFunc(_SC("While"), &SqDictionary::While)
|
||||||
|
@ -231,6 +231,18 @@ struct SqDictionary
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether an element exists.
|
||||||
|
*/
|
||||||
|
bool Exists(SqKeyHash k) const
|
||||||
|
{
|
||||||
|
for (auto & e : mC)
|
||||||
|
{
|
||||||
|
if (e.first == k.mH) return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Iterate all values through a functor.
|
* Iterate all values through a functor.
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user