Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 1 of 1 for LessConstraint (0.1 sec)

  1. 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)
Back to top