fn AutoHashMap(comptime K: type, comptime V: type) type
Functions
fn capacity(self: *Self) Size
Returns the number of total elements which may be present before it is no longe…
Returns the number of total elements which may be present before it is no longer guaranteed that no allocations will be performed.
fn clearAndFree(self: *Self) void
Empty the map and release the backing allocation. This does not free keys or …
Empty the map and release the backing allocation. This does not free keys or values! Be sure to release them if they need deinitialization before calling this function.
fn clearRetainingCapacity(self: *Self) void
Empty the map, but keep the backing allocation for future use. This does not …
Empty the map, but keep the backing allocation for future use. This does not free keys or values! Be sure to release them if they need deinitialization before calling this function.
fn cloneWithAllocator(self: Self, new_allocator: Allocator) Allocator.Error!Self
Creates a copy of this map, using a specified allocator
fn cloneWithAllocatorAndContext(self: Self, new_allocator: Allocator, new_ctx: anytype) Allocator.Error!HashMap(K, V, @TypeOf(new_ctx), max_load_percentage)
Creates a copy of this map, using a specified allocator and context.
fn cloneWithContext(self: Self, new_ctx: anytype) Allocator.Error!HashMap(K, V, @TypeOf(new_ctx), max_load_percentage)
Creates a copy of this map, using a specified context
fn deinit(self: *Self) void
Release the backing array and invalidate this map. This does not deinit keys,…
Release the backing array and invalidate this map. This does not deinit keys, values, or the context! If your keys or values need to be released, ensure that that is done before calling this function.
fn ensureTotalCapacity(self: *Self, expected_count: Size) Allocator.Error!void
Increases capacity, guaranteeing that insertions up until the
expected_count
…Increases capacity, guaranteeing that insertions up until the
expected_count
will not cause an allocation, and therefore cannot fail.fn ensureUnusedCapacity(self: *Self, additional_count: Size) Allocator.Error!void
Increases capacity, guaranteeing that insertions up until
additional_count
**…Increases capacity, guaranteeing that insertions up until
additional_count
more items will not cause an allocation, and therefore cannot fail.fn fetchPut(self: *Self, key: K, value: V) Allocator.Error!?KV
Inserts a new
Entry
into the hash map, returning the previous one, if any.fn fetchRemove(self: *Self, key: K) ?KV
Removes a value from the map and returns the removed kv pair.
fn getOrPut(self: *Self, key: K) Allocator.Error!GetOrPutResult
If key exists this function cannot fail. If there is an existing item with `key…
fn getOrPutAdapted(self: *Self, key: anytype, ctx: anytype) Allocator.Error!GetOrPutResult
If key exists this function cannot fail. If there is an existing item with `key…
fn getOrPutAssumeCapacity(self: *Self, key: K) GetOrPutResult
If there is an existing item with
key
, then the resultEntry
pointers point…If there is an existing item with
key
, then the resultEntry
pointers point to it, and found_existing is true. Otherwise, puts a new item with undefined value, and theEntry
pointers point to it. Caller should then initialize the value (but not the key). If a new entry needs to be stored, this function asserts there is enough capacity to store it.fn getOrPutAssumeCapacityAdapted(self: *Self, key: anytype, ctx: anytype) GetOrPutResult
If there is an existing item with
key
, then the resultEntry
pointers point…If there is an existing item with
key
, then the resultEntry
pointers point to it, and found_existing is true. Otherwise, puts a new item with undefined value, and theEntry
pointers point to it. Caller must then initialize the key and value. If a new entry needs to be stored, this function asserts there is enough capacity to store it.fn init(allocator: Allocator) Self
Create a managed hash map with an empty context. If the context is not zero-siz…
Create a managed hash map with an empty context. If the context is not zero-sized, you must use initContext(allocator, ctx) instead.
fn iterator(self: *const Self) Iterator
Create an iterator over the entries in the map. The iterator is invalidated if …
Create an iterator over the entries in the map. The iterator is invalidated if the map is modified.
fn keyIterator(self: *const Self) KeyIterator
Create an iterator over the keys in the map. The iterator is invalidated if the…
Create an iterator over the keys in the map. The iterator is invalidated if the map is modified.
fn move(self: *Self) Self
Set the map to an empty state, making deinitialization a no-op, and returning a…
Set the map to an empty state, making deinitialization a no-op, and returning a copy of the original.
fn put(self: *Self, key: K, value: V) Allocator.Error!void
Clobbers any existing data. To detect if a put would clobber existing data, see…
Clobbers any existing data. To detect if a put would clobber existing data, see
getOrPut
.fn putAssumeCapacity(self: *Self, key: K, value: V) void
Asserts there is enough capacity to store the new key-value pair. Clobbers any …
Asserts there is enough capacity to store the new key-value pair. Clobbers any existing data. To detect if a put would clobber existing data, see
getOrPutAssumeCapacity
.fn putAssumeCapacityNoClobber(self: *Self, key: K, value: V) void
Asserts there is enough capacity to store the new key-value pair. Asserts that …
Asserts there is enough capacity to store the new key-value pair. Asserts that it does not clobber any existing data. To detect if a put would clobber existing data, see
getOrPutAssumeCapacity
.fn putNoClobber(self: *Self, key: K, value: V) Allocator.Error!void
Inserts a key-value pair into the hash map, asserting that no previous entry wi…
Inserts a key-value pair into the hash map, asserting that no previous entry with the same key is already present
fn removeByPtr(self: *Self, key_ptr: *K) void
Delete the entry with key pointed to by key_ptr from the hash map. key_ptr is a…
Delete the entry with key pointed to by key_ptr from the hash map. key_ptr is assumed to be a valid pointer to a key that is present in the hash map.
fn valueIterator(self: *const Self) ValueIterator
Create an iterator over the values in the map. The iterator is invalidated if t…
Create an iterator over the values in the map. The iterator is invalidated if the map is modified.
Values
Entry | undefined | An entry, containing pointers to a key and value stored in the map |
GetOrPutResult | undefined | The type returned from getOrPut and variants |
Hash | undefined | The integer type that is the result of hashing |
Iterator | undefined | The iterator type returned by iterator() |
KV | undefined | A copy of a key and value which are no longer in the map |
KeyIterator | undefined | |
Size | undefined | The integer type used to store the size of the map |
Unmanaged | undefined | The type of the unmanaged hash map underlying this wrapper |
ValueIterator | undefined |