Zig 0.17.0-dev (Split by item)

This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is the Zig library itself.

unguardedInsertionContext

Insertion sort that assumes items[a-1] exists and is <= all elements in [a, b), allowing the inner loop to skip the bounds check.

pdq.unguardedInsertionContext
fn unguardedInsertionContext(a: usize, b: usize, context: anytype) void

File

lib/std/sort/pdq.zig:140

Code

fn unguardedInsertionContext(a: usize, b: usize, context: anytype) void {
    var i = a + 1;
    while (i < b) : (i += 1) {
        var j = i;
        while (context.lessThan(j, j - 1)) : (j -= 1) {
            context.swap(j, j - 1);
        }
    }
}