zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit dcfc851349a660da4b4b37c25959905d3323a824 (tree)
parent cbe3dd12c4885adb1323742b53df1079e8efb97f
Author: Ryan Liptak <squeek502@hotmail.com>
Date:   Tue, 30 Sep 2025 00:42:31 -0700

ArrayHashMapWithAllocator: add `sortUnstable` fn alongside `sort`

Diffstat:
Mlib/std/array_hash_map.zig | 9+++++++++
1 file changed, 9 insertions(+), 0 deletions(-)

diff --git a/lib/std/array_hash_map.zig b/lib/std/array_hash_map.zig @@ -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. ///