strToNumberHash function
Returns the specified string as a hash value of type number. The return value can also be negative.
Implementation
int strToNumberHash(String str) {
if (str.isEmpty) {
return 0;
}
int hash = 0;
for (int i = 0; i < str.length; i++) {
hash = ((hash << 5) - hash) + str.codeUnitAt(i);
hash &= 0xFFFFFFFF;
}
return hash;
}