- Sort Score
- Result 10 results
- Languages All
Results 1 - 1 of 1 for LessConstraint (0.32 sec)
-
src/cmd/compile/internal/test/testdata/mysort/mysort.go
// license that can be found in the LICENSE file. // Generic sort function, tested with two different pointer types. package mysort import ( "fmt" ) type LessConstraint[T any] interface { Less(T) bool } //go:noinline func Sort[T LessConstraint[T]](x []T) { n := len(x) for i := 1; i < n; i++ { for j := i; j > 0 && x[j].Less(x[j-1]); j-- { x[j], x[j-1] = x[j-1], x[j] } } }
Registered: Wed Jun 12 16:32:35 UTC 2024 - Last Modified: Tue Oct 12 20:53:52 UTC 2021 - 762 bytes - Viewed (0)