Version 0.60.0

str::hash_code

Return the hash code of a string.

Signatures

  •   int hash_code( string& input )

Details

The hash code for a string s is computed as the sum

s[0]*31(N-1) + s[1]*31(N-2) + ... + s[N-1]

where s[i] is code value of the ith character of the string and N is the length of the string.

Example

 #import( "std/str.sps" )
 echo( str::hash_code( "Hello" ) )
 

Output

 69609650
 

Return value

The hash code of the string.

Parameters

input

String the hash code is calculated of.

See also

🗙

Search results for