Recursive function looking for the entry in array by hash
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(mimic_stack_entry), | intent(in), | dimension(:), pointer | :: | entries | List of entries to search |
|
integer | :: | num_entries | Number of entries |
|||
integer, | intent(in) | :: | hash | Hash ID of the function |
pointer to a found entry or null pointer
recursive function find_entry(entries, num_entries, hash) result(entry)
!> List of entries to search
type(mimic_stack_entry), dimension(:), pointer, intent(in) :: entries
!> Number of entries
integer :: num_entries
!> Hash ID of the function
integer, intent(in) :: hash
!> pointer to a found entry or null pointer
type(mimic_stack_entry), pointer :: entry
integer :: i, j
do i = 1, num_entries
if (entries(i)%hash == hash) then
entry => entries(i)
return
endif
if (associated(entries(i)%children)) then
do j = 1, entries(i)%num_children
entry => find_entry(entries(i)%children, entries(i)%num_children, hash)
if (associated(entry)) then
return
end if
end do
end if
end do
entry => null()
end function find_entry