dict_str_i4_haskey Function

private function dict_str_i4_haskey(dict, key) result(res)

Checks whether a given key is currently stored in the dictionary.

Arguments

TypeIntentOptionalAttributesName
type(dict_str_i4_type), intent(inout) :: dict
character(len=default_string_length) :: key

Return Value logical


Contents

Source Code


Source Code

      FUNCTION dict_str_i4_haskey(dict, key) RESULT(res)
      !! Checks whether a given key is currently stored in the dictionary.
         TYPE(dict_str_i4_type), intent(inout)  :: dict
         CHARACTER(LEN=default_string_length)                                        :: key
         LOGICAL                                               :: res
         TYPE(private_item_type_str_i4), POINTER                      :: item
         INTEGER(KIND=int_8)                                   :: hash, idx

         IF (.not. ASSOCIATED(dict%buckets)) &
            DBCSR_ABORT("dict_str_i4_haskey: dictionary is not initialized.")

         res = .FALSE.
         IF (dict%size == 0) RETURN

         hash = hash_str (key)
         idx = MOD(hash, INT(size(dict%buckets), KIND=int_8)) + 1

         item => dict%buckets(idx)%p
         do while (ASSOCIATED(item))
            IF (item%hash == hash) THEN
               IF (item%key == key) THEN
                  res = .TRUE.
                  return
               END IF
            END IF
            item => item%next
         end do

      END FUNCTION dict_str_i4_haskey