sort_search_position Interface

interface
public module function sort_search_position(keys, n_search, upper) result(pos)

Arguments

Type IntentOptional Attributes Name
type(sort_key_buf), intent(in) :: keys(:)

the keys; row n_search+1 is the target.

integer(kind=int64), intent(in) :: n_search

rows being searched.

logical, intent(in) :: upper

.true. for upper_bound.

Return Value integer(kind=int64)

1-based insertion point in 1..n_search+1.

Description

Binary search for the target row, which the caller APPENDED as row n_search + 1.

Preserve the appending. It is what removes any compare-a-row-against-a-value arm and so makes drift from the sort comparator structurally impossible — Risk-34.