binary_search Interface

public interface binary_search

Binary search of a sorted array. (assumed to be in ascending order)


Module Procedures

private function item_binary_search(val, vec) result(jloc)

Arguments

Type IntentOptional Attributes Name
class(item), intent(in) :: val

value to match in vec

class(item), intent(in), dimension(:) :: vec

array to search (it is assumed to be sorted)

Return Value integer

the first matched index in vec (if not found, 0 is returned)

private function int32_binary_search(val, vec) result(jloc)

Arguments

Type IntentOptional Attributes Name
integer(kind=int32), intent(in) :: val

value to match in vec

integer(kind=int32), intent(in), dimension(:) :: vec

array to search (it is assumed to be sorted)

Return Value integer

the first matched index in vec (if not found, 0 is returned)

private function int64_binary_search(val, vec) result(jloc)

Arguments

Type IntentOptional Attributes Name
integer(kind=int64), intent(in) :: val

value to match in vec

integer(kind=int64), intent(in), dimension(:) :: vec

array to search (it is assumed to be sorted)

Return Value integer

the first matched index in vec (if not found, 0 is returned)

private function real64_binary_search(val, vec) result(jloc)

Arguments

Type IntentOptional Attributes Name
real(kind=real64), intent(in) :: val

value to match in vec

real(kind=real64), intent(in), dimension(:) :: vec

array to search (it is assumed to be sorted)

Return Value integer

the first matched index in vec (if not found, 0 is returned)

private function real32_binary_search(val, vec) result(jloc)

Arguments

Type IntentOptional Attributes Name
real(kind=real32), intent(in) :: val

value to match in vec

real(kind=real32), intent(in), dimension(:) :: vec

array to search (it is assumed to be sorted)

Return Value integer

the first matched index in vec (if not found, 0 is returned)