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) intParameters & Attributes
| Name | Type | Description |
|---|---|---|
| a | []float64 | Sorted input slice. |
| x | float64 | Input 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))}