fn AutoHashMap(comptime K: type, comptime V: type) type

Parameters

K: type,
V: type,

Fields

unmanaged: Unmanaged,
allocator: Allocator,
ctx: Context,

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 clone(self: Self) Allocator.Error!Self

Creates a copy of this map, using the same allocator

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 contains(self: Self, key: K) bool

Check if the map contains a key

fn containsAdapted(self: Self, key: anytype, ctx: anytype) bool

No documentation provided.

fn count(self: Self) Size

Return the number of items in the map.

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 fetchPutAssumeCapacity(self: *Self, key: K, value: V) ?KV

Inserts a new Entry into the hash map, returning the previous one, if any. If…

Inserts a new Entry into the hash map, returning the previous one, if any. If insertion happuns, asserts there is enough capacity without allocating.

fn fetchRemove(self: *Self, key: K) ?KV

Removes a value from the map and returns the removed kv pair.

fn fetchRemoveAdapted(self: *Self, key: anytype, ctx: anytype) ?KV

No documentation provided.

fn get(self: Self, key: K) ?V

Finds the value associated with a key in the map

fn getAdapted(self: Self, key: anytype, ctx: anytype) ?V

No documentation provided.

fn getEntry(self: Self, key: K) ?Entry

Finds the key and value associated with a key in the map

fn getEntryAdapted(self: Self, key: anytype, ctx: anytype) ?Entry

No documentation provided.

fn getKey(self: Self, key: K) ?K

Finds the actual key associated with an adapted key in the map

fn getKeyAdapted(self: Self, key: anytype, ctx: anytype) ?K

No documentation provided.

fn getKeyPtr(self: Self, key: K) ?*K

No documentation provided.

fn getKeyPtrAdapted(self: Self, key: anytype, ctx: anytype) ?*K

No documentation provided.

fn getOrPut(self: *Self, key: K) Allocator.Error!GetOrPutResult

If key exists this function cannot fail. If there is an existing item with `key…

If key exists this function cannot fail. If there is an existing item with key, then the result Entry pointers point to it, and found_existing is true. Otherwise, puts a new item with undefined value, and the Entry pointers point to it. Caller should then initialize the value (but not the 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…

If key exists this function cannot fail. If there is an existing item with key, then the result Entry pointers point to it, and found_existing is true. Otherwise, puts a new item with undefined key and value, and the Entry pointers point to it. Caller must then initialize the key and value.

fn getOrPutAssumeCapacity(self: *Self, key: K) GetOrPutResult

If there is an existing item with key, then the result Entry pointers point…

If there is an existing item with key, then the result Entry pointers point to it, and found_existing is true. Otherwise, puts a new item with undefined value, and the Entry 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 result Entry pointers point…

If there is an existing item with key, then the result Entry pointers point to it, and found_existing is true. Otherwise, puts a new item with undefined value, and the Entry 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 getOrPutValue(self: *Self, key: K, value: V) Allocator.Error!Entry

No documentation provided.

fn getPtr(self: Self, key: K) ?*V

No documentation provided.

fn getPtrAdapted(self: Self, key: anytype, ctx: anytype) ?*V

No documentation provided.

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 initContext(allocator: Allocator, ctx: Context) Self

Create a managed hash map with a context

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 remove(self: *Self, key: K) bool

If there is an Entry with a matching key, it is deleted from the hash map, an…

If there is an Entry with a matching key, it is deleted from the hash map, and this function returns true. Otherwise this function returns false.

fn removeAdapted(self: *Self, key: anytype, ctx: anytype) bool

No documentation provided.

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