, c
SDBM
sdbm (public redomplementation ndbm). , , . . - hash (i) = hash (i - 1) * 65599 + str [i]; , , - , gawk. [ duff-device], 65599 , . , berkeley db (. sleepycat) .
static unsigned long
sdbm(str)
unsigned char *str;
{
unsigned long hash = 0;
int c;
while (c = *str++)
hash = c + (hash << 6) + (hash << 16) - hash;
return hash;
}
vb, .
,
newHash = the character (c) + (previousHashValue * 2^6) +
(previousHashValue * 2^16) -
previousHashValue**
previousHashValue = newHash
source
share