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 standard library.
std › multi_array_list › MultiArrayList › sortInternal Private Function sortInternal Doc Source Private Function std.multi_array_list.MultiArrayList.sortInternal
fn sortInternal (self : Self , a : usize , b : usize , ctx : anytype , comptime mode : std .sort .Mode ) void Params File multi_array_list.zig: 589
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616 fn sortInternal (self : Self , a : usize , b : usize , ctx : anytype , comptime mode : std .sort .Mode ) void {
const sort_context : struct {
sub_ctx : @TypeOf (ctx ),
slice : Slice ,
pub fn swap (sc : @This (), a_index : usize , b_index : usize ) void {
inline for (field_types , 0 ..) |field_type , i | {
if (@sizeOf (field_type ) != 0 ) {
const field : Field = @fromBackingInt (@intCast (i ));
const ptr = sc .slice .items (field );
mem .swap (field_type , &ptr [a_index ], &ptr [b_index ]);
}
}
}
pub fn lessThan (sc : @This (), a_index : usize , b_index : usize ) bool {
return sc .sub_ctx .lessThan (a_index , b_index );
}
} = .{
.sub_ctx = ctx ,
.slice = self .slice (),
};
switch (mode ) {
.stable => mem .sortContext (a , b , sort_context ),
.unstable => mem .sortUnstableContext (a , b , sort_context ),
}
}
ctxhas the following method:fn lessThan(ctx: @TypeOf(ctx), a_index: usize, b_index: usize) bool