Standard library / sort

sort.SearchFloat64s()

Returns the first index at which the target can be inserted in an ascending sorted slice. Check equality separately for membership. Expected stdout: '1 3\n'.

Formal Syntax & Structure

go syntaxgo
func SearchFloat64s(a []float64, x float64) int

Parameters & Attributes

NameTypeDescription
a[]float64Sorted input slice.
xfloat64Input value or collection to process.

Return Value

int

Returns the first index at which the target can be inserted in an ascending sorted slice. Check equality separately for membership.

Working Example

Example Snippetgo
package main
import (  "fmt"  "sort")
func main() {  fmt.Println(sort.SearchFloat64s([]float64{1.5, 2.5, 3.5}, 2.5), sort.SearchFloat64s([]float64{1.5, 2.5, 3.5}, 4.5))}
Go Reference