fn unguardedInsertionContext(a: usize, b: usize, context: anytype) void a: usizeb: usizecontext140
141
142
143
144
145
146
147
148fn 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);
}
}
}
Insertion sort that assumes
items[a-1]exists and is <= all elements in[a, b), allowing the inner loop to skip the bounds check.