Hash the key.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(hash_table), | intent(in) | :: | self | The hash table. |
||
class(*), | intent(in) | :: | key | Key to hash. |
Bucket index corresponding to the key.
elemental function hash(self, key) result(bucket)
!---------------------------------------------------------------------------------------------------------------------------------
!< Hash the key.
!---------------------------------------------------------------------------------------------------------------------------------
class(hash_table), intent(in) :: self !< The hash table.
class(*), intent(in) :: key !< Key to hash.
integer(I4P) :: bucket !< Bucket index corresponding to the key.
type(key_base) :: key_ !< Key to hash casted to [[key_base]].
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
bucket = 0
if (self%is_initialized_) then
key_ = key_base(key=key, buckets_number=self%buckets_number)
bucket = key_%hash(buckets_number=self%buckets_number)
endif
!---------------------------------------------------------------------------------------------------------------------------------
endfunction hash