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 › sort › block › findLastForward Private Function findLastForward Doc Source Private Function std.sort.block.findLastForward
fn findLastForward (
comptime T : type ,
items : []T ,
value : T ,
range : Range ,
unique : usize ,
context : anytype ,
comptime lessThan : fn (@TypeOf (context ), lhs : T , rhs : T ) bool ,
) usize Params T : type items : []T value : T range : Range unique : usize context lessThan : fn (@TypeOf (context ), lhs : T , rhs : T ) bool File sort/block.zig: 895
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915 fn findLastForward (
comptime T : type ,
items : []T ,
value : T ,
range : Range ,
unique : usize ,
context : anytype ,
comptime lessThan : fn (@TypeOf (context ), lhs : T , rhs : T ) bool ,
) usize {
if (range .length () == 0 ) return range .start ;
const skip = @max (range .length () / unique , @as (usize , 1 ));
var index = range .start + skip ;
while (!lessThan (context , value , items [index - 1 ])) : (index += skip ) {
if (index >= range .end - skip ) {
return binaryLast (T , items , value , Range .init (index , range .end ), context , lessThan );
}
}
return binaryLast (T , items , value , Range .init (index - skip , index ), context , lessThan );
}