Fetch the root entry, reporting an error when the heap is empty.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(heap_t), | intent(in) | :: | self | |||
| integer(kind=int64), | intent(out) | :: | key | |||
| integer(kind=int32), | intent(out) | :: | payload | |||
| type(error_t), | intent(out), | optional | :: | err |
function root_entry(self, key, payload, err) result(ok) !! Fetch the root entry, reporting an error when the heap is empty. class(heap_t), intent(in) :: self integer(int64), intent(out) :: key integer(int32), intent(out) :: payload type(error_t), intent(out), optional :: err logical :: ok if (self%n_entries == 0) then key = 0_int64 payload = 0_int32 ok = .false. if (present(err)) then call err%set(ERROR_VALIDATION, "pic_heap: cannot read the root of an empty heap") end if return end if key = self%keys(1) payload = self%payloads(1) ok = .true. end function root_entry