authorgravatar for squeek502@hotmail.comRyan Liptak <squeek502@hotmail.com> 2025-09-30 00:42:31-07:00
committergravatar for squeek502@hotmail.comRyan Liptak <squeek502@hotmail.com> 2025-09-30 19:33:03-07:00
logdcfc851349a660da4b4b37c25959905d3323a824
tree6a24113ac922cda3dada74967d841b5e00e8e404
parentcbe3dd12c4885adb1323742b53df1079e8efb97f

ArrayHashMapWithAllocator: add `sortUnstable` fn alongside `sort`


1 files changed, 9 insertions(+), 0 deletions(-)

lib/std/array_hash_map.zig+9
...@@ -460,10 +460,19 @@ pub fn ArrayHashMapWithAllocator(...@@ -460,10 +460,19 @@ pub fn ArrayHashMapWithAllocator(
460 /// Sorts the entries and then rebuilds the index.460 /// Sorts the entries and then rebuilds the index.
461 /// `sort_ctx` must have this method:461 /// `sort_ctx` must have this method:
462 /// `fn lessThan(ctx: @TypeOf(ctx), a_index: usize, b_index: usize) bool`462 /// `fn lessThan(ctx: @TypeOf(ctx), a_index: usize, b_index: usize) bool`
463 /// Uses a stable sorting algorithm.
463 pub fn sort(self: *Self, sort_ctx: anytype) void {464 pub fn sort(self: *Self, sort_ctx: anytype) void {
464 return self.unmanaged.sortContext(sort_ctx, self.ctx);465 return self.unmanaged.sortContext(sort_ctx, self.ctx);
465 }466 }
466467
468 /// Sorts the entries and then rebuilds the index.
469 /// `sort_ctx` must have this method:
470 /// `fn lessThan(ctx: @TypeOf(ctx), a_index: usize, b_index: usize) bool`
471 /// Uses an unstable sorting algorithm.
472 pub fn sortUnstable(self: *Self, sort_ctx: anytype) void {
473 return self.unmanaged.sortUnstableContext(sort_ctx, self.ctx);
474 }
475
467 /// Shrinks the underlying `Entry` array to `new_len` elements and476 /// Shrinks the underlying `Entry` array to `new_len` elements and
468 /// discards any associated index entries. Keeps capacity the same.477 /// discards any associated index entries. Keeps capacity the same.
469 ///478 ///