Standard library / sort
sort.Float64Slice.Search()
Returns lower-bound insertion index in an ascending sorted receiver. Does not sort the receiver first or return a found flag. Expected stdout: '1 3\n'.
Formal Syntax & Structure
go syntaxgo
func (p Float64Slice) Search(x float64) intParameters & Attributes
| Name | Type | Description |
|---|---|---|
| x | float64 | Input value or collection to process. |
Return Value
int
Returns lower-bound insertion index in an ascending sorted receiver. Does not sort the receiver first or return a found flag.
Working Example
Example Snippetgo
package main
import ( "fmt" "sort")
func main() { a := sort.Float64Slice([]float64{1.5, 2.5, 3.5}) fmt.Println(a.Search(2.5), a.Search(4.5))}