mirror of
https://github.com/ziglang/zig.git
synced 2024-11-15 16:45:27 +00:00
improve documentation of std.sort.*Context functions (#16145)
This commit is contained in:
parent
d881d841ed
commit
dae516dbdf
@ -34,7 +34,9 @@ pub fn insertion(
|
||||
|
||||
/// Stable in-place sort. O(n) best case, O(pow(n, 2)) worst case.
|
||||
/// O(1) memory (no allocator required).
|
||||
/// Sorts in ascending order with respect to the given `lessThan` function.
|
||||
/// `context` must have methods `swap` and `lessThan`,
|
||||
/// which each take 2 `usize` parameters indicating the index of an item.
|
||||
/// Sorts in ascending order with respect to `lessThan`.
|
||||
pub fn insertionContext(a: usize, b: usize, context: anytype) void {
|
||||
assert(a <= b);
|
||||
|
||||
@ -73,7 +75,9 @@ pub fn heap(
|
||||
|
||||
/// Unstable in-place sort. O(n*log(n)) best case, worst case and average case.
|
||||
/// O(1) memory (no allocator required).
|
||||
/// Sorts in ascending order with respect to the given `lessThan` function.
|
||||
/// `context` must have methods `swap` and `lessThan`,
|
||||
/// which each take 2 `usize` parameters indicating the index of an item.
|
||||
/// Sorts in ascending order with respect to `lessThan`.
|
||||
pub fn heapContext(a: usize, b: usize, context: anytype) void {
|
||||
assert(a <= b);
|
||||
// build the heap in linear time.
|
||||
|
@ -37,8 +37,9 @@ const Hint = enum {
|
||||
|
||||
/// Unstable in-place sort. O(n) best case, O(n*log(n)) worst case and average case.
|
||||
/// O(log(n)) memory (no allocator required).
|
||||
///
|
||||
/// Sorts in ascending order with respect to the given `lessThan` function.
|
||||
/// `context` must have methods `swap` and `lessThan`,
|
||||
/// which each take 2 `usize` parameters indicating the index of an item.
|
||||
/// Sorts in ascending order with respect to `lessThan`.
|
||||
pub fn pdqContext(a: usize, b: usize, context: anytype) void {
|
||||
// slices of up to this length get sorted using insertion sort.
|
||||
const max_insertion = 24;
|
||||
|
Loading…
Reference in New Issue
Block a user