ensureTotalCapacityContext
Function parameters
Parameters
Type definitions in this namespace
Types
An `ArrayHashMap` with default hash and equal functions.
Functions
- AutoArrayHashMap
- An `ArrayHashMap` with default hash and equal functions.
- AutoArrayHashMapUnmanaged
- An `ArrayHashMapUnmanaged` with default hash and equal functions.
- StringArrayHashMap
- An `ArrayHashMap` with strings as keys.
- StringArrayHashMapUnmanaged
- An `ArrayHashMapUnmanaged` with strings as keys.
- ArrayHashMap
- Deprecated in favor of `ArrayHashMapWithAllocator` (no code changes needed)
- ArrayHashMapWithAllocator
- A hash table of keys and values, each stored sequentially.
- ArrayHashMapUnmanaged
- A hash table of keys and values, each stored sequentially.
Source
Implementation
pub fn ensureTotalCapacityContext(self: *Self, gpa: Allocator, new_capacity: usize, ctx: Context) Oom!void {
self.pointer_stability.lock();
defer self.pointer_stability.unlock();
try self.entries.ensureTotalCapacity(gpa, new_capacity);
if (new_capacity <= linear_scan_max) return;
if (self.index_header) |header| if (new_capacity <= header.capacity()) return;
const new_bit_index = try IndexHeader.findBitIndex(new_capacity);
const new_header = try IndexHeader.alloc(gpa, new_bit_index);
if (self.index_header) |old_header| old_header.free(gpa);
self.insertAllEntriesIntoNewHeader(if (store_hash) {} else ctx, new_header);
self.index_header = new_header;
}