| ... | ... | @@ -454,14 +454,23 @@ pub fn ArrayHashMap( |
| 454 | 454 | return self.unmanaged.sortContext(sort_ctx, self.ctx); |
| 455 | 455 | } |
| 456 | 456 | |
| 457 | | /// Shrinks the underlying `Entry` array to `new_len` elements and discards any associated |
| 458 | | /// index entries. Keeps capacity the same. |
| 457 | /// Shrinks the underlying `Entry` array to `new_len` elements and |
| 458 | /// discards any associated index entries. Keeps capacity the same. |
| 459 | /// |
| 460 | /// Asserts the discarded entries remain initialized and capable of |
| 461 | /// performing hash and equality checks. Any deinitialization of |
| 462 | /// discarded entries must take place *after* calling this function. |
| 459 | 463 | pub fn shrinkRetainingCapacity(self: *Self, new_len: usize) void { |
| 460 | 464 | return self.unmanaged.shrinkRetainingCapacityContext(new_len, self.ctx); |
| 461 | 465 | } |
| 462 | 466 | |
| 463 | | /// Shrinks the underlying `Entry` array to `new_len` elements and discards any associated |
| 464 | | /// index entries. Reduces allocated capacity. |
| 467 | /// Shrinks the underlying `Entry` array to `new_len` elements and |
| 468 | /// discards any associated index entries. Reduces allocated capacity. |
| 469 | /// |
| 470 | /// Asserts the discarded entries remain initialized and capable of |
| 471 | /// performing hash and equality checks. It is a bug to call this |
| 472 | /// function if the discarded entries require deinitialization. For |
| 473 | /// that use case, `shrinkRetainingCapacity` can be used instead. |
| 465 | 474 | pub fn shrinkAndFree(self: *Self, new_len: usize) void { |
| 466 | 475 | return self.unmanaged.shrinkAndFreeContext(self.allocator, new_len, self.ctx); |
| 467 | 476 | } |
| ... | ... | @@ -1359,13 +1368,24 @@ pub fn ArrayHashMapUnmanaged( |
| 1359 | 1368 | self.insertAllEntriesIntoNewHeader(if (store_hash) {} else ctx, header); |
| 1360 | 1369 | } |
| 1361 | 1370 | |
| 1362 | | /// Shrinks the underlying `Entry` array to `new_len` elements and discards any associated |
| 1363 | | /// index entries. Keeps capacity the same. |
| 1371 | /// Shrinks the underlying `Entry` array to `new_len` elements and |
| 1372 | /// discards any associated index entries. Keeps capacity the same. |
| 1373 | /// |
| 1374 | /// Asserts the discarded entries remain initialized and capable of |
| 1375 | /// performing hash and equality checks. Any deinitialization of |
| 1376 | /// discarded entries must take place *after* calling this function. |
| 1364 | 1377 | pub fn shrinkRetainingCapacity(self: *Self, new_len: usize) void { |
| 1365 | 1378 | if (@sizeOf(ByIndexContext) != 0) |
| 1366 | 1379 | @compileError("Cannot infer context " ++ @typeName(Context) ++ ", call shrinkRetainingCapacityContext instead."); |
| 1367 | 1380 | return self.shrinkRetainingCapacityContext(new_len, undefined); |
| 1368 | 1381 | } |
| 1382 | |
| 1383 | /// Shrinks the underlying `Entry` array to `new_len` elements and |
| 1384 | /// discards any associated index entries. Keeps capacity the same. |
| 1385 | /// |
| 1386 | /// Asserts the discarded entries remain initialized and capable of |
| 1387 | /// performing hash and equality checks. Any deinitialization of |
| 1388 | /// discarded entries must take place *after* calling this function. |
| 1369 | 1389 | pub fn shrinkRetainingCapacityContext(self: *Self, new_len: usize, ctx: Context) void { |
| 1370 | 1390 | self.pointer_stability.lock(); |
| 1371 | 1391 | defer self.pointer_stability.unlock(); |
| ... | ... | @@ -1381,13 +1401,27 @@ pub fn ArrayHashMapUnmanaged( |
| 1381 | 1401 | self.entries.shrinkRetainingCapacity(new_len); |
| 1382 | 1402 | } |
| 1383 | 1403 | |
| 1384 | | /// Shrinks the underlying `Entry` array to `new_len` elements and discards any associated |
| 1385 | | /// index entries. Reduces allocated capacity. |
| 1404 | /// Shrinks the underlying `Entry` array to `new_len` elements and |
| 1405 | /// discards any associated index entries. Reduces allocated capacity. |
| 1406 | /// |
| 1407 | /// Asserts the discarded entries remain initialized and capable of |
| 1408 | /// performing hash and equality checks. It is a bug to call this |
| 1409 | /// function if the discarded entries require deinitialization. For |
| 1410 | /// that use case, `shrinkRetainingCapacity` can be used instead. |
| 1386 | 1411 | pub fn shrinkAndFree(self: *Self, allocator: Allocator, new_len: usize) void { |
| 1387 | 1412 | if (@sizeOf(ByIndexContext) != 0) |
| 1388 | 1413 | @compileError("Cannot infer context " ++ @typeName(Context) ++ ", call shrinkAndFreeContext instead."); |
| 1389 | 1414 | return self.shrinkAndFreeContext(allocator, new_len, undefined); |
| 1390 | 1415 | } |
| 1416 | |
| 1417 | /// Shrinks the underlying `Entry` array to `new_len` elements and |
| 1418 | /// discards any associated index entries. Reduces allocated capacity. |
| 1419 | /// |
| 1420 | /// Asserts the discarded entries remain initialized and capable of |
| 1421 | /// performing hash and equality checks. It is a bug to call this |
| 1422 | /// function if the discarded entries require deinitialization. For |
| 1423 | /// that use case, `shrinkRetainingCapacityContext` can be used |
| 1424 | /// instead. |
| 1391 | 1425 | pub fn shrinkAndFreeContext(self: *Self, allocator: Allocator, new_len: usize, ctx: Context) void { |
| 1392 | 1426 | self.pointer_stability.lock(); |
| 1393 | 1427 | defer self.pointer_stability.unlock(); |