16.05.2017, 12:36
(
Last edited by Gammix; 17/05/2017 at 03:37 AM.
)
Here is the modified getIndex function, using sdbm algorithm.
(since i am using this for my libraries now, so i don't mind posting them here!)
PHP Code:
stock getIndex(array[][], const string[], size = sizeof array)
{
new hash;
new i;
new c;
while ((c = string[i++]) != EOS)
{
hash = c + (hash << 6) + (hash << 16) - hash;
}
hash %= size;
if (array[hash][0] && strcmp(array[hash], string))
{
return -1;
}
return hash;
}