Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

c++ the hash function with 31 const

int hashFunction(string key) {
    int hashCode = 0;
    for (int i = 0; i < key.length(); i++) {
        hashCode += key[i] * pow(PRIME_CONST, i);
    }
    return hashCode;
}
Source by dev.to #
 
PREVIOUS NEXT
Tagged: #hash #function #const
ADD COMMENT
Topic
Name
6+5 =