// Convenience wrappers for common cases.
// SearchInts searches for x in a sorted slice of ints and returns the index
-// as specified by Search. The return value is the index to insert x if x is
+// as specified by [Search]. The return value is the index to insert x if x is
// not present (it could be len(a)).
// The slice must be sorted in ascending order.
func SearchInts(a []int, x int) int {
}
// SearchFloat64s searches for x in a sorted slice of float64s and returns the index
-// as specified by Search. The return value is the index to insert x if x is not
+// as specified by [Search]. The return value is the index to insert x if x is not
// present (it could be len(a)).
// The slice must be sorted in ascending order.
func SearchFloat64s(a []float64, x float64) int {
return Search(len(a), func(i int) bool { return a[i] >= x })
}
-// Search returns the result of applying SearchInts to the receiver and x.
+// Search returns the result of applying [SearchInts] to the receiver and x.
func (p IntSlice) Search(x int) int { return SearchInts(p, x) }
-// Search returns the result of applying SearchFloat64s to the receiver and x.
+// Search returns the result of applying [SearchFloat64s] to the receiver and x.
func (p Float64Slice) Search(x float64) int { return SearchFloat64s(p, x) }
-// Search returns the result of applying SearchStrings to the receiver and x.
+// Search returns the result of applying [SearchStrings] to the receiver and x.
func (p StringSlice) Search(x string) int { return SearchStrings(p, x) }
//
// The sort is not guaranteed to be stable: equal elements
// may be reversed from their original order.
-// For a stable sort, use SliceStable.
+// For a stable sort, use [SliceStable].
//
// The less function must satisfy the same requirements as
// the Interface type's Less method.
//
-// Note: in many situations, the newer slices.SortFunc function is more
+// Note: in many situations, the newer [slices.SortFunc] function is more
// ergonomic and runs faster.
func Slice(x any, less func(i, j int) bool) {
rv := reflectlite.ValueOf(x)
// The less function must satisfy the same requirements as
// the Interface type's Less method.
//
-// Note: in many situations, the newer slices.SortStableFunc function is more
+// Note: in many situations, the newer [slices.SortStableFunc] function is more
// ergonomic and runs faster.
func SliceStable(x any, less func(i, j int) bool) {
rv := reflectlite.ValueOf(x)
// SliceIsSorted reports whether the slice x is sorted according to the provided less function.
// It panics if x is not a slice.
//
-// Note: in many situations, the newer slices.IsSortedFunc function is more
+// Note: in many situations, the newer [slices.IsSortedFunc] function is more
// ergonomic and runs faster.
func SliceIsSorted(x any, less func(i, j int) bool) bool {
rv := reflectlite.ValueOf(x)
// It makes one call to data.Len to determine n and O(n*log(n)) calls to
// data.Less and data.Swap. The sort is not guaranteed to be stable.
//
-// Note: in many situations, the newer slices.SortFunc function is more
+// Note: in many situations, the newer [slices.SortFunc] function is more
// ergonomic and runs faster.
func Sort(data Interface) {
n := data.Len()
// IsSorted reports whether data is sorted.
//
-// Note: in many situations, the newer slices.IsSortedFunc function is more
+// Note: in many situations, the newer [slices.IsSortedFunc] function is more
// ergonomic and runs faster.
func IsSorted(data Interface) bool {
n := data.Len()
// Ints sorts a slice of ints in increasing order.
//
-// Note: as of Go 1.22, this function simply calls slices.Sort.
+// Note: as of Go 1.22, this function simply calls [slices.Sort].
func Ints(x []int) { intsImpl(x) }
// Float64s sorts a slice of float64s in increasing order.
// Not-a-number (NaN) values are ordered before other values.
//
-// Note: as of Go 1.22, this function simply calls slices.Sort.
+// Note: as of Go 1.22, this function simply calls [slices.Sort].
func Float64s(x []float64) { float64sImpl(x) }
// Strings sorts a slice of strings in increasing order.
//
-// Note: as of Go 1.22, this function simply calls slices.Sort.
+// Note: as of Go 1.22, this function simply calls [slices.Sort].
func Strings(x []string) { stringsImpl(x) }
// IntsAreSorted reports whether the slice x is sorted in increasing order.
//
-// Note: as of Go 1.22, this function simply calls slices.IsSorted.
+// Note: as of Go 1.22, this function simply calls [slices.IsSorted].
func IntsAreSorted(x []int) bool { return intsAreSortedImpl(x) }
// Float64sAreSorted reports whether the slice x is sorted in increasing order,
// with not-a-number (NaN) values before any other values.
//
-// Note: as of Go 1.22, this function simply calls slices.IsSorted.
+// Note: as of Go 1.22, this function simply calls [slices.IsSorted].
func Float64sAreSorted(x []float64) bool { return float64sAreSortedImpl(x) }
// StringsAreSorted reports whether the slice x is sorted in increasing order.
//
-// Note: as of Go 1.22, this function simply calls slices.IsSorted.
+// Note: as of Go 1.22, this function simply calls [slices.IsSorted].
func StringsAreSorted(x []string) bool { return stringsAreSortedImpl(x) }
// Notes on stable sorting: