-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed
Labels
contributor friendlyThis issue is limited in scope and/or knowledge of Zig internals.This issue is limited in scope and/or knowledge of Zig internals.enhancementSolving this issue will likely involve adding new logic or components to the codebase.Solving this issue will likely involve adding new logic or components to the codebase.optimizationstandard libraryThis issue involves writing Zig code for the standard library.This issue involves writing Zig code for the standard library.
Milestone
Description
These functions are available:
zig/lib/std/array_hash_map.zig
Lines 1229 to 1243 in d68f39b
| /// 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` | |
| pub inline fn sort(self: *Self, sort_ctx: anytype) void { | |
| if (@sizeOf(ByIndexContext) != 0) | |
| @compileError("Cannot infer context " ++ @typeName(Context) ++ ", call sortContext instead."); | |
| return self.sortContext(sort_ctx, undefined); | |
| } | |
| pub fn sortContext(self: *Self, sort_ctx: anytype, ctx: Context) void { | |
| self.entries.sort(sort_ctx); | |
| const header = self.index_header orelse return; | |
| header.reset(); | |
| self.insertAllEntriesIntoNewHeader(if (store_hash) {} else ctx, header); | |
| } |
However, unstable sort is preferred when possible. This API should offer unstable sorting as well.
Metadata
Metadata
Assignees
Labels
contributor friendlyThis issue is limited in scope and/or knowledge of Zig internals.This issue is limited in scope and/or knowledge of Zig internals.enhancementSolving this issue will likely involve adding new logic or components to the codebase.Solving this issue will likely involve adding new logic or components to the codebase.optimizationstandard libraryThis issue involves writing Zig code for the standard library.This issue involves writing Zig code for the standard library.
Type
Projects
Status
Uncategorized