sdbm-hash algorithm
I added the sdbm hash algorithm
This commit is contained in:
13
snippets/sdbm_hash.md
Normal file
13
snippets/sdbm_hash.md
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
|
||||||
|
This function implements the **sdbm** hash-algorithm.
|
||||||
|
It uses the charCodeAt-methode and the shift-operator.
|
||||||
|
|
||||||
|
``` js
|
||||||
|
function sdbm(s) {
|
||||||
|
var hashCode = new Number();
|
||||||
|
for (var i = 0; i < s.length; i++) {
|
||||||
|
hashCode = s.charCodeAt(i) + (hashCode << 6) + (hashCode << 16) - hashCode;
|
||||||
|
}
|
||||||
|
return hashCode;
|
||||||
|
}
|
||||||
|
```
|
||||||
Reference in New Issue
Block a user