fn HashMapUnmanaged(comptime K: type, comptime V: type, comptime Context: type, comptime max_load_percentage: u64) type

A HashMap based on open addressing and linear probing. A lookup or modification typically occurs only 2 cache misses. No order is guaranteed and any modification invalidates live iterators. It achieves good performance with quite high load factors (by default, grow is triggered at 80% full) and only one byte of overhead per element. The struct itself is only 16 bytes for a small footprint. This comes at the price of handling size with u32, which should be reasonable enough for almost all uses. Deletions are achieved with tombstones.

Parameters

K: type,
V: type,
Context: type,
max_load_percentage: u64,

Fields

metadata: ?[*]Metadata = null,

Pointer to the metadata.

size: Size = 0,

Current number of elements in the hashmap.

available: Size = 0,

Number of available slots before a grow is needed to satisfy the max_load_percentage.

Functions

fn capacity(self: *const Self) Size

No documentation provided.

fn clearAndFree(self: *Self, allocator: Allocator) void

No documentation provided.

fn clearRetainingCapacity(self: *Self) void

No documentation provided.

fn clone(self: Self, allocator: Allocator) Allocator.Error!Self

No documentation provided.

fn cloneContext(self: Self, allocator: Allocator, new_ctx: anytype) Allocator.Error!HashMapUnmanaged(K, V, @TypeOf(new_ctx), max_load_percentage)

No documentation provided.

fn contains(self: *const Self, key: K) bool

Return true if there is a value associated with key in the map.

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

No documentation provided.

fn containsContext(self: *const Self, key: K, ctx: Context) bool

No documentation provided.

fn count(self: *const Self) Size

No documentation provided.

fn deinit(self: *Self, allocator: Allocator) void

No documentation provided.

fn ensureTotalCapacity(self: *Self, allocator: Allocator, new_size: Size) Allocator.Error!void

No documentation provided.

fn ensureTotalCapacityContext(self: *Self, allocator: Allocator, new_size: Size, ctx: Context) Allocator.Error!void

No documentation provided.

fn ensureUnusedCapacity(self: *Self, allocator: Allocator, additional_size: Size) Allocator.Error!void

No documentation provided.

fn ensureUnusedCapacityContext(self: *Self, allocator: Allocator, additional_size: Size, ctx: Context) Allocator.Error!void

No documentation provided.

fn fetchPut(self: *Self, allocator: Allocator, 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 happens, asserts there is enough capacity without allocating.

fn fetchPutAssumeCapacityContext(self: *Self, key: K, value: V, ctx: Context) ?KV

No documentation provided.

fn fetchPutContext(self: *Self, allocator: Allocator, key: K, value: V, ctx: Context) Allocator.Error!?KV

No documentation provided.

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

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 then returned from this function.

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

No documentation provided.

fn fetchRemoveContext(self: *Self, key: K, ctx: Context) ?KV

No documentation provided.

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

Get a copy of the value associated with key, if present.

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

No documentation provided.

fn getContext(self: Self, key: K, ctx: Context) ?V

No documentation provided.

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

No documentation provided.

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

No documentation provided.

fn getEntryContext(self: Self, key: K, ctx: Context) ?Entry

No documentation provided.

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

Get a copy of the actual key associated with adapted key, if present.

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

No documentation provided.

fn getKeyContext(self: Self, key: K, ctx: Context) ?K

No documentation provided.

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

Get an optional pointer to the actual key associated with adapted key, if presen…

Get an optional pointer to the actual key associated with adapted key, if present.

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

No documentation provided.

fn getKeyPtrContext(self: Self, key: K, ctx: Context) ?*K

No documentation provided.

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

No documentation provided.

fn getOrPutAdapted(self: *Self, allocator: Allocator, key: anytype, key_ctx: anytype) Allocator.Error!GetOrPutResult

No documentation provided.

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

No documentation provided.

fn getOrPutAssumeCapacityAdapted(self: *Self, key: anytype, ctx: anytype) GetOrPutResult

No documentation provided.

fn getOrPutAssumeCapacityContext(self: *Self, key: K, ctx: Context) GetOrPutResult

No documentation provided.

fn getOrPutContext(self: *Self, allocator: Allocator, key: K, ctx: Context) Allocator.Error!GetOrPutResult

No documentation provided.

fn getOrPutContextAdapted(self: *Self, allocator: Allocator, key: anytype, key_ctx: anytype, ctx: Context) Allocator.Error!GetOrPutResult

No documentation provided.

fn getOrPutValue(self: *Self, allocator: Allocator, key: K, value: V) Allocator.Error!Entry

No documentation provided.

fn getOrPutValueContext(self: *Self, allocator: Allocator, key: K, value: V, ctx: Context) Allocator.Error!Entry

No documentation provided.

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

Get an optional pointer to the value associated with key, if present.

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

No documentation provided.

fn getPtrContext(self: Self, key: K, ctx: Context) ?*V

No documentation provided.

fn iterator(self: *const Self) Iterator

No documentation provided.

fn keyIterator(self: *const Self) KeyIterator

No documentation provided.

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 promote(self: Self, allocator: Allocator) Managed

No documentation provided.

fn promoteContext(self: Self, allocator: Allocator, ctx: Context) Managed

No documentation provided.

fn put(self: *Self, allocator: Allocator, key: K, value: V) Allocator.Error!void

Insert an entry if the associated key is not already present, otherwise update p…

Insert an entry if the associated key is not already present, otherwise update preexisting value.

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 putAssumeCapacityContext(self: *Self, key: K, value: V, ctx: Context) void

No documentation provided.

fn putAssumeCapacityNoClobber(self: *Self, key: K, value: V) void

Insert an entry in the map. Assumes it is not already present, and that no allo…

Insert an entry in the map. Assumes it is not already present, and that no allocation is needed.

fn putAssumeCapacityNoClobberContext(self: *Self, key: K, value: V, ctx: Context) void

No documentation provided.

fn putContext(self: *Self, allocator: Allocator, key: K, value: V, ctx: Context) Allocator.Error!void

No documentation provided.

fn putNoClobber(self: *Self, allocator: Allocator, key: K, value: V) Allocator.Error!void

Insert an entry in the map. Assumes it is not already present.

fn putNoClobberContext(self: *Self, allocator: Allocator, key: K, value: V, ctx: Context) Allocator.Error!void

No documentation provided.

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

No documentation provided.

fn valueIterator(self: *const Self) ValueIterator

No documentation provided.

Values

KeyIterator
undefined
Managed
undefined
ValueIterator
undefined