functionname_hashpureprivate
pure integer function name_hash(name, size)
The hash of name, FNV-1a, as a position in 1:size, where size is a power of 2.
Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
| name | character(len=*) | in | the name | |
| size | integer | in | the number of slots |
Result
| Name | Type | Attributes | Description |
|---|---|---|---|
| name_hash | integer |
Source
Show the code
pure integer function name_hash(name, size)
character(len=*), intent(in) :: name !! the name
integer, intent(in) :: size !! the number of slots
integer(int64) :: h
integer :: k
h = 2166136261_int64
do k = 1, len(name)
h = iand(ieor(h, int(iachar(name(k:k)), int64))*16777619_int64, 4294967295_int64)
end do
name_hash = int(iand(h, int(size - 1, int64))) + 1
end function name_hash