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 standard library. Private Function
fnmergeInternal(
comptimeT: type,
items: []T,
A: Range,
B: Range,
buffer: Range,
context: anytype,
comptimelessThan: fn (@TypeOf(context), lhs: T, rhs: T) bool,
) void {
// whenever we find a value to add to the final array, swap it with the value that's already in that spot// when this algorithm is finished, 'buffer' will contain its original contents, but in a different ordervarA_count: usize = 0;
varB_count: usize = 0;
varinsert: usize = 0;
if (B.length() > 0andA.length() > 0) {
while (true) {
if (!lessThan(context, items[B.start + B_count], items[buffer.start + A_count])) {
mem.swap(T, &items[A.start + insert], &items[buffer.start + A_count]);
A_count += 1;
insert += 1;
if (A_count >= A.length()) break;
} else {
mem.swap(T, &items[A.start + insert], &items[B.start + B_count]);
B_count += 1;
insert += 1;
if (B_count >= B.length()) break;
}
}
}
// swap the remainder of A into the final arrayblockSwap(T, items, buffer.start + A_count, A.start + insert, A.length() - A_count);
}
merge operation using an internal buffer