| ... | ... | @@ -399,6 +399,14 @@ pub fn ArrayHashMap( |
| 399 | 399 | return other.promoteContext(allocator, ctx); |
| 400 | 400 | } |
| 401 | 401 | |
| 402 | /// Set the map to an empty state, making deinitialization a no-op, and |
| 403 | /// returning a copy of the original. |
| 404 | pub fn move(self: *Self) Self { |
| 405 | const result = self.*; |
| 406 | self.unmanaged = .{}; |
| 407 | return result; |
| 408 | } |
| 409 | |
| 402 | 410 | /// Rebuilds the key indexes. If the underlying entries has been modified directly, users |
| 403 | 411 | /// can call `reIndex` to update the indexes to account for these new entries. |
| 404 | 412 | pub fn reIndex(self: *Self) !void { |
| ... | ... | @@ -1149,6 +1157,8 @@ pub fn ArrayHashMapUnmanaged( |
| 1149 | 1157 | errdefer other.entries.deinit(allocator); |
| 1150 | 1158 | |
| 1151 | 1159 | if (self.index_header) |header| { |
| 1160 | // TODO: I'm pretty sure this could be memcpy'd instead of |
| 1161 | // doing all this work. |
| 1152 | 1162 | const new_header = try IndexHeader.alloc(allocator, header.bit_index); |
| 1153 | 1163 | other.insertAllEntriesIntoNewHeader(if (store_hash) {} else ctx, new_header); |
| 1154 | 1164 | other.index_header = new_header; |
| ... | ... | @@ -1156,6 +1166,14 @@ pub fn ArrayHashMapUnmanaged( |
| 1156 | 1166 | return other; |
| 1157 | 1167 | } |
| 1158 | 1168 | |
| 1169 | /// Set the map to an empty state, making deinitialization a no-op, and |
| 1170 | /// returning a copy of the original. |
| 1171 | pub fn move(self: *Self) Self { |
| 1172 | const result = self.*; |
| 1173 | self.* = .{}; |
| 1174 | return result; |
| 1175 | } |
| 1176 | |
| 1159 | 1177 | /// Rebuilds the key indexes. If the underlying entries has been modified directly, users |
| 1160 | 1178 | /// can call `reIndex` to update the indexes to account for these new entries. |
| 1161 | 1179 | pub fn reIndex(self: *Self, allocator: Allocator) !void { |
| ... | ... | @@ -1163,6 +1181,7 @@ pub fn ArrayHashMapUnmanaged( |
| 1163 | 1181 | @compileError("Cannot infer context " ++ @typeName(Context) ++ ", call reIndexContext instead."); |
| 1164 | 1182 | return self.reIndexContext(allocator, undefined); |
| 1165 | 1183 | } |
| 1184 | |
| 1166 | 1185 | pub fn reIndexContext(self: *Self, allocator: Allocator, ctx: Context) !void { |
| 1167 | 1186 | if (self.entries.capacity <= linear_scan_max) return; |
| 1168 | 1187 | // We're going to rebuild the index header and replace the existing one (if any). The |