Skip to content

Commit

Permalink
follow x/exp/slices
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterRK committed May 18, 2022
1 parent 4e4320e commit 9021d7f
Show file tree
Hide file tree
Showing 11 changed files with 901 additions and 1,051 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## API for builtin types
```go
func BinarySearch[E constraints.Ordered](list []E, x E) int
func BinarySearch[E constraints.Ordered](list []E, x E) (int, bool)
func IsSorted[E constraints.Ordered](list []E) bool
func Sort[E constraints.Ordered](list []E)
func SortStable[E constraints.Ordered](list []E)
Expand All @@ -15,7 +15,7 @@ type Order[E any] struct {
RefLess func(a, b *E) bool
}

func (od *Order[E]) BinarySearch(list []E, x E) int
func (od *Order[E]) BinarySearch(list []E, x E) (int, bool)
func (od *Order[E]) IsSorted(list []E) bool
func (od *Order[E]) Sort(list []E)
func (od *Order[E]) SortStable(list []E)
Expand All @@ -24,7 +24,7 @@ func (od *Order[E]) SortWithOption(list []E, stable, inplace bool)

## Func API for custom types
```go
func BinarySearchFunc[E any](list []E, x E, less func(a, b E) bool) int
func BinarySearchFunc[E any](list []E, x E, less func(a, b E) bool) (int, bool)
func IsSortedFunc[E any](list []E, less func(a, b E) bool) bool
func SortFunc[E any](list []E, less func(a, b E) bool)
func SortStableFunc[E any](list []E, less func(a, b E) bool)
Expand Down
2 changes: 1 addition & 1 deletion cache_amd64.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions cpuid_amd64.s
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2022 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.

TEXT ·cpuid(SB), $0
MOVL eax+0(FP), AX
MOVL ecx+4(FP), CX
Expand Down
8 changes: 4 additions & 4 deletions genzfunc.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Copyright 2021 The Go Authors. All rights reserved.
// Copyright 2022 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.

//go:build ignore

// This program is run via "go generate" (via a directive in sort.go)
// This program is run via "go generate" (via a directive in sort_ordered.go)
// to generate zfunc_a.go & zfunc_b.go.

package main
Expand All @@ -24,7 +24,7 @@ var hackedFuncs = make(map[string]bool)

func main() {
fset := token.NewFileSet()
af, err := parser.ParseFile(fset, "sort.go", nil, 0)
af, err := parser.ParseFile(fset, "sort_ordered.go", nil, 0)
if err != nil {
log.Fatal(err)
}
Expand Down Expand Up @@ -111,7 +111,7 @@ func rewriteCalls(n ast.Node) ast.Visitor {

var header = `// Code generated from sort.go using genzfunc.go; DO NOT EDIT.
// Copyright 2021 The Go Authors. All rights reserved.
// Copyright 2022 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.
Expand Down
181 changes: 0 additions & 181 deletions order.go

This file was deleted.

40 changes: 0 additions & 40 deletions search_test.go

This file was deleted.

Loading

0 comments on commit 9021d7f

Please sign in to comment.