# BisectPy

## Index

BisectPy.bisect_leftFunction
bisect_left(a, x, lo = 1, hi = length(a) + 1)

Return the index where to insert item x in array a, assuming a is in an non-decreasing order.

The return value i is such that all e in a[:(i - 1)] have e < x, and all e in a[i:] have e >= x. So if x already appears in the array, insert!(a, i, x) will insert just before the leftmost x already there.

Arguments

Optional args lo (default 1) and hi (default length(a) + 1) bound the slice of a to be searched.

Examples

julia> bisect_left([1, 2, 3, 4, 5], 3.5)
4

julia> bisect_left([1, 2, 3, 4, 5], 2)
2

julia> bisect_left([1, 2, 3, 3, 3, 5], 3)
3
BisectPy.bisect_rightFunction
bisect_right(a, x, lo = 1, hi = length(a) + 1)

Return the index where to insert item x in array a, assuming a is in an non-decreasing order.

The return value i is such that all e in a[:(i - 1)] have e <= x, and all e in a[i:] have e > x. So if x already appears in the array, insert!(a, i, x) will insert just after the rightmost x already there.

Arguments

Optional args lo (default 1) and hi (default length(a) + 1) bound the slice of a to be searched.

Examples

julia> bisect_right([1, 2, 3, 4, 5], 3.5)
4

julia> bisect_right([1, 2, 3, 4, 5], 2)
3

julia> bisect_right([1, 2, 3, 3, 3, 5], 3)
6
BisectPy.find_geMethod
find_ge(a, x)

Find leftmost item greater than or equal to x in a.

BisectPy.find_gtMethod
find_gt(a, x)

Find leftmost value greater than x in a.

BisectPy.find_leMethod
find_le(a, x)

Find rightmost value less than or equal to x in a.

BisectPy.indexMethod
index(a, x)

Locate the leftmost value exactly equal to x in a.

BisectPy.insort_leftFunction
insort_left(a, x, lo = 1, hi = nothing)

Insert item x in array a, and keep it sorted assuming a is sorted.

If x is already in a, insert it to the left of the leftmost x. Optional args lo (default 1) and hi (default length(a)) bound the slice of a to be searched.

BisectPy.insort_rightFunction
insort_right(a, x, lo = 1, hi = nothing)

Insert item x in array a, and keep it sorted assuming a is sorted.

If x is already in a, insert it to the right of the rightmost x. Optional args lo (default 1) and hi (default length(a)) bound the slice of a to be searched.