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 › findFirstBackward Private Function findFirstBackward Doc Source Private Function std.sort.block.findFirstBackward
fn findFirstBackward (
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: 873
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893 fn findFirstBackward (
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 .end - skip ;
while (index > range .start and !lessThan (context , items [index - 1 ], value )) : (index -= skip ) {
if (index < range .start + skip ) {
return binaryFirst (T , items , value , Range .init (range .start , index ), context , lessThan );
}
}
return binaryFirst (T , items , value , Range .init (index , index + skip ), context , lessThan );
}