dict_str_i4_items Function

private function dict_str_i4_items(dict) result(items)

Returns a pointer to an array of all key/value-items stored in the dictionary. Caution: The caller is responsible for deallocating targeted array after usage.

Arguments

Type IntentOptional Attributes Name
type(dict_str_i4_type), intent(inout) :: dict

Return Value type(dict_str_i4_item_type), dimension(:), POINTER


Source Code

      FUNCTION dict_str_i4_items(dict) RESULT(items)
      !! Returns a pointer to an array of all key/value-items stored in the dictionary.
      !! Caution: The caller is responsible for deallocating targeted array after usage.
         TYPE(dict_str_i4_type), intent(inout)  :: dict
         TYPE(dict_str_i4_item_type), dimension(:), POINTER :: items

         TYPE(private_item_type_str_i4), POINTER  :: item
         INTEGER :: i, j

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

         allocate (items(dict%size))
         j = 1
         do i = 1, size(dict%buckets)
            item => dict%buckets(i)%p
            do while (ASSOCIATED(item))
               items(j)%key =item%key
               items(j)%value =item%value
               j = j + 1
               item => item%next
            end do
         end do

         IF (j /= dict%size + 1) &
            DBCSR_ABORT("dict_str_i4_items: assertion failed!")
      END FUNCTION dict_str_i4_items