mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 05:44:20 +00:00
ArrayHashMapWithAllocator: add sortUnstable fn alongside sort
This commit is contained in:
parent
cbe3dd12c4
commit
dcfc851349
1 changed files with 9 additions and 0 deletions
|
|
@ -460,10 +460,19 @@ pub fn ArrayHashMapWithAllocator(
|
|||
/// Sorts the entries and then rebuilds the index.
|
||||
/// `sort_ctx` must have this method:
|
||||
/// `fn lessThan(ctx: @TypeOf(ctx), a_index: usize, b_index: usize) bool`
|
||||
/// Uses a stable sorting algorithm.
|
||||
pub fn sort(self: *Self, sort_ctx: anytype) void {
|
||||
return self.unmanaged.sortContext(sort_ctx, self.ctx);
|
||||
}
|
||||
|
||||
/// Sorts the entries and then rebuilds the index.
|
||||
/// `sort_ctx` must have this method:
|
||||
/// `fn lessThan(ctx: @TypeOf(ctx), a_index: usize, b_index: usize) bool`
|
||||
/// Uses an unstable sorting algorithm.
|
||||
pub fn sortUnstable(self: *Self, sort_ctx: anytype) void {
|
||||
return self.unmanaged.sortUnstableContext(sort_ctx, self.ctx);
|
||||
}
|
||||
|
||||
/// Shrinks the underlying `Entry` array to `new_len` elements and
|
||||
/// discards any associated index entries. Keeps capacity the same.
|
||||
///
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue