vector_djb_hash Function

private pure function vector_djb_hash(r) result(hash)

DJB hash algorithm for a integer(ip) vector.

See also

  • J. Shahbazian, Fortran hashing algorithm, July 6, 2013 Fortran Dev

Arguments

Type IntentOptional Attributes Name
integer(kind=ip), intent(in), dimension(:) :: r

the vector

Return Value integer(kind=ip)

the hash value


Called by

proc~~vector_djb_hash~2~~CalledByGraph proc~vector_djb_hash~2 aoc_cache_module::vector_djb_hash proc~get_from_cache~2 aoc_cache_module::function_cache%get_from_cache proc~get_from_cache~2->proc~vector_djb_hash~2 proc~get_all_pieces_above problem_22::get_all_pieces_above proc~get_all_pieces_above->proc~get_from_cache~2 proc~get_all_pieces_above->proc~get_all_pieces_above proc~get_all_pieces_below problem_22::get_all_pieces_below proc~get_all_pieces_below->proc~get_from_cache~2 proc~get_all_pieces_below->proc~get_all_pieces_below proc~go~4 problem_12b::go proc~go~4->proc~get_from_cache~2 proc~ipoint problem_12b::ipoint proc~go~4->proc~ipoint proc~ipound problem_12b::ipound proc~go~4->proc~ipound proc~index_in_queue~2 problem_17::index_in_queue proc~index_in_queue~2->proc~get_from_cache~2 proc~check~2 problem_17::check proc~check~2->proc~index_in_queue~2 proc~ipoint->proc~go~4 proc~ipound->proc~go~4 program~problem_12b problem_12b program~problem_12b->proc~go~4 program~problem_22 problem_22 program~problem_22->proc~get_all_pieces_above program~problem_22->proc~get_all_pieces_below program~problem_17~2 problem_17 program~problem_17~2->proc~check~2

Source Code

    pure function vector_djb_hash(r) result(hash)

    integer(ip),dimension(:),intent(in) :: r     !! the vector
    integer(ip)                         :: hash  !! the hash value

    integer :: i !! counter

    hash = 5381_ip

    do i=1,size(r)
        hash = ishft(hash,5_ip) + hash + r(i)
    end do

    end function vector_djb_hash