mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 05:44:20 +00:00
Merge c80bb983cc into 9082b004b6
This commit is contained in:
commit
19d3870b5c
4 changed files with 558 additions and 714 deletions
|
|
@ -629,10 +629,13 @@ pub fn sortUnstable(
|
|||
std.sort.pdq(T, items, context, lessThanFn);
|
||||
}
|
||||
|
||||
/// TODO: currently this just calls `insertionSortContext`. The block sort implementation
|
||||
/// in this file needs to be adapted to use the sort context.
|
||||
/// Sorts a range [a, b) using a stable algorithm (maintains relative order of equal elements) with custom context.
|
||||
/// This is a lower-level interface for sorting that works with indices instead of slices.
|
||||
///
|
||||
/// The context must provide lessThan(a_idx, b_idx) and swap(a_idx, b_idx) methods and optionally
|
||||
/// a rotate(start_idx, end_idx, amount) method (see `mem.rotate`).
|
||||
pub fn sortContext(a: usize, b: usize, context: anytype) void {
|
||||
std.sort.insertionContext(a, b, context);
|
||||
std.sort.blockContext(a, b, context);
|
||||
}
|
||||
|
||||
/// Sorts a range [a, b) using an unstable algorithm with custom context.
|
||||
|
|
|
|||
|
|
@ -191,7 +191,7 @@ pub fn MultiArrayList(comptime T: type) type {
|
|||
return lhs.alignment > rhs.alignment;
|
||||
}
|
||||
};
|
||||
@setEvalBranchQuota(3 * fields.len * std.math.log2(fields.len));
|
||||
@setEvalBranchQuota(10 * fields.len * std.math.log2(fields.len));
|
||||
mem.sort(Data, &data, {}, Sort.lessThan);
|
||||
var sizes_bytes: [fields.len]usize = undefined;
|
||||
var field_indexes: [fields.len]usize = undefined;
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ const math = std.math;
|
|||
pub const Mode = enum { stable, unstable };
|
||||
|
||||
pub const block = @import("sort/block.zig").block;
|
||||
pub const blockContext = @import("sort/block.zig").blockContext;
|
||||
pub const pdq = @import("sort/pdq.zig").pdq;
|
||||
pub const pdqContext = @import("sort/pdq.zig").pdqContext;
|
||||
|
||||
|
|
@ -159,7 +160,7 @@ const sort_funcs = &[_]fn (comptime type, anytype, anytype, comptime anytype) vo
|
|||
};
|
||||
|
||||
const context_sort_funcs = &[_]fn (usize, usize, anytype) void{
|
||||
// blockContext,
|
||||
blockContext,
|
||||
pdqContext,
|
||||
insertionContext,
|
||||
heapContext,
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue