callback_lookup Subroutine

private subroutine callback_lookup(this, hval, pos, t_found, loc_verify)

Generic lookup routine, using an external routine for verification DOES NOT TO THE SAME AS direct_lookup @param[in] hval hash value of the index to look up @param[out] pos on return, the matching entry @param[out] t_found on return, true if and only if index was found @param[in] verify function to check if an entry matches

Type Bound

shared_rhash_t

Arguments

Type IntentOptional Attributes Name
class(shared_rhash_t), intent(in) :: this
integer(kind=int64), intent(in) :: hval
integer(kind=int64), intent(out) :: pos
logical, intent(out) :: t_found
private function loc_verify(i) result(match)
Arguments
Type IntentOptional Attributes Name
integer(kind=int64), intent(in) :: i
Return Value logical

Contents

Source Code


Source Code

    subroutine callback_lookup(this, hval, pos, t_found, loc_verify)
        class(shared_rhash_t), intent(in) :: this
        integer(int64), intent(in) :: hval
        integer(int64), intent(out) :: pos
        logical, intent(out) :: t_found

        integer(int64) :: lower, upper, i

        interface
            function loc_verify(i) result(match)
                use constants
                integer(int64), intent(in) :: i
                logical :: match
            end function loc_verify
        end interface

        lower = this%hval_offsets%ptr(hval) + 1
        upper = this%hval_offsets%ptr(hval + 1)

        t_found = .false.
        pos = 0
        do i = lower, upper
            if (loc_verify(this%indices%ptr(i))) then
                pos = this%indices%ptr(i)
                t_found = .true.
                return
            end if
        end do
    end subroutine callback_lookup