Documentation ¶
Overview ¶
Package search implements a simple binary search to allow finding the index of any element in an ordered slice of comparable elements
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ComparableSlice ¶
func ComparableSlice[T Comparable[T]](slice []T, element T) int
ComparableSlice takes an ordered slice of comparable elements (Comparable[T]) and the element to search for, and performs a binary search on the slice. It returns the index of given element, if found, or otherwise -1
func Slice ¶
func Slice[T constraints.Ordered](slice []T, element T) int
Slice takes an ordered slice of comparable elements (constraints.Ordered) and the element to search for, and performs a binary search on the slice. It returns the index of given element, if found, or otherwise -1
Types ¶
type Comparable ¶
Comparable exposes a method for comparing current struct, with another struct
Click to show internal directories.
Click to hide internal directories.