Rename slice.sort_proc to slice.sort_by; add slice.sort_by_key

This commit is contained in:
gingerBill
2020-10-16 14:55:36 +01:00
parent 289908e0b8
commit 41f6a684e1
4 changed files with 43 additions and 18 deletions
+4 -4
View File
@@ -290,7 +290,7 @@ _insertion_sort :: proc(it: Interface, a, b: int) {
// @(deprecated="use sort.sort or slice.sort_proc")
// @(deprecated="use sort.sort or slice.sort_by")
bubble_sort_proc :: proc(array: $A/[]$T, f: proc(T, T) -> int) {
assert(f != nil);
count := len(array);
@@ -347,7 +347,7 @@ bubble_sort :: proc(array: $A/[]$T) where intrinsics.type_is_ordered(T) {
}
}
// @(deprecated="use sort.sort or slice.sort_proc")
// @(deprecated="use sort.sort or slice.sort_by")
quick_sort_proc :: proc(array: $A/[]$T, f: proc(T, T) -> int) {
assert(f != nil);
a := array;
@@ -412,7 +412,7 @@ _log2 :: proc(x: int) -> int {
return res;
}
// @(deprecated="use sort.sort or slice.sort_proc")
// @(deprecated="use sort.sort or slice.sort_by")
merge_sort_proc :: proc(array: $A/[]$T, f: proc(T, T) -> int) {
merge :: proc(a: A, start, mid, end: int, f: proc(T, T) -> int) {
s, m := start, mid;
@@ -497,7 +497,7 @@ merge_sort :: proc(array: $A/[]$T) where intrinsics.type_is_ordered(T) {
}
// @(deprecated="use sort.sort or slice.sort_proc")
// @(deprecated="use sort.sort or slice.sort_by")
heap_sort_proc :: proc(array: $A/[]$T, f: proc(T, T) -> int) {
sift_proc :: proc(a: A, pi: int, n: int, f: proc(T, T) -> int) #no_bounds_check {
p := pi;