Add TrieGetSize native.

This commit is contained in:
Arkshine
2014-05-03 16:09:31 +02:00
parent 12a8864532
commit f3bce9ecfd
3 changed files with 39 additions and 22 deletions

View File

@ -262,6 +262,20 @@ static cell AMX_NATIVE_CALL TrieDestroy(AMX *amx, cell *params)
return 0;
}
// native TrieGetSize(Trie:handle);
static cell AMX_NATIVE_CALL TrieGetSize(AMX *amx, cell *params)
{
CellTrie *t = g_TrieHandles.lookup(params[1]);
if (t == NULL)
{
LogError(amx, AMX_ERR_NATIVE, "Invalid map handle provided (%d)", params[1]);
return 0;
}
return t->map.elements();
}
AMX_NATIVE_INFO trie_Natives[] =
{
{ "TrieCreate", TrieCreate },
@ -279,6 +293,8 @@ AMX_NATIVE_INFO trie_Natives[] =
{ "TrieKeyExists", TrieKeyExists },
{ "TrieDestroy", TrieDestroy },
{ "TrieGetSize", TrieGetSize },
{ NULL, NULL }
};