- Sort Score
- Result 10 results
- Languages All
Results 1 - 10 of 10 for IsSortedFunc (0.28 sec)
-
src/slices/sort_test.go
} data := make(intPairs, n) // random distribution for i := 0; i < len(data); i++ { data[i].a = rand.Intn(m) } if IsSortedFunc(data, intPairCmp) { t.Fatalf("terrible rand.rand") } data.initB() SortStableFunc(data, intPairCmp) if !IsSortedFunc(data, intPairCmp) { t.Errorf("Stable didn't sort %d ints", n) } if !data.inOrder(false) { t.Errorf("Stable wasn't stable on %d ints", n)
Registered: Wed Jun 12 16:32:35 UTC 2024 - Last Modified: Thu May 09 19:20:55 UTC 2024 - 9.5K bytes - Viewed (0) -
src/slices/iter_test.go
n, m := 1000, 100 data := make(intPairs, n) for i := range data { data[i].a = rand.IntN(m) } data.initB() s := intPairs(SortedStableFunc(Values(data), intPairCmp)) if !IsSortedFunc(s, intPairCmp) { t.Errorf("SortedStableFunc didn't sort %d ints", n) } if !s.inOrder(false) { t.Errorf("SortedStableFunc wasn't stable on %d ints", n) } // iterVal converts a Seq2 to a Seq.
Registered: Wed Jun 12 16:32:35 UTC 2024 - Last Modified: Fri May 10 17:28:50 UTC 2024 - 5.7K bytes - Viewed (0) -
src/sort/slice.go
} // SliceIsSorted reports whether the slice x is sorted according to the provided less function. // It panics if x is not a slice. // // Note: in many situations, the newer [slices.IsSortedFunc] function is more // ergonomic and runs faster. func SliceIsSorted(x any, less func(i, j int) bool) bool { rv := reflectlite.ValueOf(x) n := rv.Len() for i := n - 1; i > 0; i-- { if less(i, i-1) {
Registered: Wed Jun 12 16:32:35 UTC 2024 - Last Modified: Tue Nov 28 16:40:32 UTC 2023 - 1.8K bytes - Viewed (0) -
src/internal/trace/batchcursor_test.go
l := len(heap) var removed []*batchCursor for i := 0; i < l; i++ { removed = append(removed, heap[0]) heap = heapRemove(heap, 0) checkHeap(t, heap) } if !slices.IsSortedFunc(removed, (*batchCursor).compare) { t.Fatalf("heap elements not removed in sorted order, got: %s", heapDebugString(removed)) } } func makeBatchCursor(v int64) *batchCursor {
Registered: Wed Jun 12 16:32:35 UTC 2024 - Last Modified: Fri May 17 18:48:18 UTC 2024 - 3K bytes - Viewed (0) -
src/slices/sort.go
for i := len(x) - 1; i > 0; i-- { if cmp.Less(x[i], x[i-1]) { return false } } return true } // IsSortedFunc reports whether x is sorted in ascending order, with cmp as the // comparison function as defined by [SortFunc]. func IsSortedFunc[S ~[]E, E any](x S, cmp func(a, b E) int) bool { for i := len(x) - 1; i > 0; i-- { if cmp(x[i], x[i-1]) < 0 { return false } } return true
Registered: Wed Jun 12 16:32:35 UTC 2024 - Last Modified: Wed Feb 07 23:54:41 UTC 2024 - 5.8K bytes - Viewed (0) -
src/slices/example_test.go
fmt.Println(slices.IsSorted([]int{0, 2, 1})) // Output: // true // false } func ExampleIsSortedFunc() { names := []string{"alice", "Bob", "VERA"} isSortedInsensitive := slices.IsSortedFunc(names, func(a, b string) int { return strings.Compare(strings.ToLower(a), strings.ToLower(b)) }) fmt.Println(isSortedInsensitive) fmt.Println(slices.IsSorted(names)) // Output: // true // false
Registered: Wed Jun 12 16:32:35 UTC 2024 - Last Modified: Fri May 10 17:28:50 UTC 2024 - 8.1K bytes - Viewed (0) -
src/sort/sort.go
// Reverse returns the reverse order for data. func Reverse(data Interface) Interface { return &reverse{data} } // IsSorted reports whether data is sorted. // // Note: in many situations, the newer [slices.IsSortedFunc] function is more // ergonomic and runs faster. func IsSorted(data Interface) bool { n := data.Len() for i := n - 1; i > 0; i-- { if data.Less(i, i-1) { return false } } return true
Registered: Wed Jun 12 16:32:35 UTC 2024 - Last Modified: Tue Nov 28 16:40:32 UTC 2023 - 10.1K bytes - Viewed (0) -
api/go1.21.txt
pkg slices, func Insert[$0 interface{ ~[]$1 }, $1 interface{}]($0, int, ...$1) $0 #57433 pkg slices, func IsSorted[$0 interface{ ~[]$1 }, $1 cmp.Ordered]($0) bool #60091 pkg slices, func IsSortedFunc[$0 interface{ ~[]$1 }, $1 interface{}]($0, func($1, $1) int) bool #60091 pkg slices, func Max[$0 interface{ ~[]$1 }, $1 cmp.Ordered]($0) $1 #60091
Registered: Wed Jun 12 16:32:35 UTC 2024 - Last Modified: Mon Aug 07 09:39:17 UTC 2023 - 25.6K bytes - Viewed (0) -
src/crypto/tls/tls_test.go
return +1 } t.Fatalf("two ciphersuites are equal by all criteria: %v and %v", aName, bName) panic("unreachable") } if !slices.IsSortedFunc(prefOrder, isBetter) { t.Error("preference order is not sorted according to the rules") } } } func TestVersionName(t *testing.T) {
Registered: Wed Jun 12 16:32:35 UTC 2024 - Last Modified: Thu May 23 03:10:12 UTC 2024 - 60.5K bytes - Viewed (0) -
src/cmd/vendor/golang.org/x/tools/internal/stdlib/manifest.go
{"Equal", Func, 21}, {"EqualFunc", Func, 21}, {"Grow", Func, 21}, {"Index", Func, 21}, {"IndexFunc", Func, 21}, {"Insert", Func, 21}, {"IsSorted", Func, 21}, {"IsSortedFunc", Func, 21}, {"Max", Func, 21}, {"MaxFunc", Func, 21}, {"Min", Func, 21}, {"MinFunc", Func, 21}, {"Replace", Func, 21}, {"Reverse", Func, 21}, {"Sort", Func, 21},
Registered: Wed Jun 12 16:32:35 UTC 2024 - Last Modified: Tue Apr 02 02:20:05 UTC 2024 - 534.2K bytes - Viewed (0)