feature. See also
. The project being documented here (as the example) is the Zig library itself.
block.swap
fn swap(
comptime T: type,
items: []T,
order: *[8]u8,
x: usize,
y: usize,
context: anytype,
comptime lessThan: fn (@TypeOf(context), lhs: T, rhs: T) bool,
) void
File
Code
fn swap(
comptime T: type,
items: []T,
order: *[8]u8,
x: usize,
y: usize,
context: anytype,
comptime lessThan: fn (@TypeOf(context), lhs: T, rhs: T) bool,
) void {
if (lessThan(context, items[y], items[x]) or ((order.*)[x] > (order.*)[y] and !lessThan(context, items[x], items[y]))) {
mem.swap(T, &items[x], &items[y]);
mem.swap(u8, &(order.*)[x], &(order.*)[y]);
}
}