binarysearch

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 12, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EqualRange

func EqualRange[T cmp.Ordered](arr []T, target T) (int, int)

EqualRange returns the range of indices where the target value is located in the sorted slice. If the target value is not found, it returns the range where the target value should be inserted. The slice must be sorted in non-decreasing order.

func Find

func Find[T cmp.Ordered](arr []T, target T) (int, bool)

Find returns the index of the target value in the sorted slice. If the target value is not found, it returns the index where the target value should be inserted and the second return value is false. The slice must be sorted in non-decreasing order.

func LowerBound

func LowerBound[T cmp.Ordered](arr []T, target T) int

LowerBound returns the first index of the target value in the sorted slice. If the target value is not found, it returns the index where the target value should be inserted. The slice must be sorted in non-decreasing order.

func UpperBound

func UpperBound[T cmp.Ordered](arr []T, target T) int

UpperBound returns the last index of the target value in the sorted slice. If the target value is not found, it returns the index where the target value should be inserted. The slice must be sorted in non-decreasing order.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL