aboutsummaryrefslogtreecommitdiff
path: root/lib/std/array_hash_map.zig
diff options
context:
space:
mode:
authorRyan Liptak <squeek502@hotmail.com>2025-09-30 00:42:31 -0700
committerRyan Liptak <squeek502@hotmail.com>2025-09-30 19:33:03 -0700
commitdcfc851349a660da4b4b37c25959905d3323a824 (patch)
tree6a24113ac922cda3dada74967d841b5e00e8e404 /lib/std/array_hash_map.zig
parentcbe3dd12c4885adb1323742b53df1079e8efb97f (diff)
downloadzig-dcfc851349a660da4b4b37c25959905d3323a824.tar.gz
zig-dcfc851349a660da4b4b37c25959905d3323a824.zip
ArrayHashMapWithAllocator: add `sortUnstable` fn alongside `sort`
Diffstat (limited to 'lib/std/array_hash_map.zig')
-rw-r--r--lib/std/array_hash_map.zig9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/std/array_hash_map.zig b/lib/std/array_hash_map.zig
index 02ae8895aa..e1007ff27e 100644
--- 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.
///