403Webshell
Server IP : 217.160.0.212  /  Your IP : 216.73.217.36
Web Server : Apache
System : Linux www 6.18.52-i1-ampere #1203 SMP Mon Sep 14 18:29:59 CEST 2026 aarch64
User : sws1073854427 ( 1073854427)
PHP Version : 8.4.23
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /usr/lib/go-1.23/src/cmd/compile/internal/test/testdata/mysort/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/lib/go-1.23/src/cmd/compile/internal/test/testdata/mysort/mysort.go
// Copyright 2021 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// 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]
		}
	}
}

type MyInt struct {
	Value int
}

func (a *MyInt) Less(b *MyInt) bool {
	return a.Value < b.Value
}

//go:noinline
func F() {
	sl1 := []*MyInt{&MyInt{4}, &MyInt{3}, &MyInt{8}, &MyInt{7}}
	Sort(sl1)
	fmt.Printf("%v %v %v %v\n", sl1[0], sl1[1], sl1[2], sl1[3])
}

Youez - 2016 - github.com/yon3zu
LinuXploit