root_entry Function

private function root_entry(self, key, payload, err) result(ok)

Fetch the root entry, reporting an error when the heap is empty.

Arguments

Type IntentOptional 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

Return Value logical


Calls

proc~~root_entry~~CallsGraph proc~root_entry root_entry proc~error_set error_t%error_set proc~root_entry->proc~error_set

Called by

proc~~root_entry~~CalledByGraph proc~root_entry root_entry proc~heap_peek heap_t%heap_peek proc~heap_peek->proc~root_entry proc~heap_pop heap_t%heap_pop proc~heap_pop->proc~root_entry proc~a_star a_star proc~a_star->proc~heap_pop proc~dijkstra dijkstra proc~dijkstra->proc~heap_pop

Source Code

   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