DJB hash algorithm for a string.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(json_hash_table), | intent(in) | :: | me | |||
| character(kind=CK, len=*), | intent(in) | :: | key |
function hash_table_hash(me, key) result(hash_value) class(json_hash_table), intent(in) :: me character(kind=CK,len=*), intent(in) :: key integer(kind=IK) :: hash_value integer(IK) :: hash integer(IK) :: i !! counter hash = 5381_IK do i = 1, len(key) hash = ishft(hash, 5_IK) + hash + iachar(key(i:i), kind=IK) ! hash * 33 + c end do ! Map to bucket index hash_value = int(modulo(hash, int(me%capacity, IK)), IK) end function hash_table_hash