fn StringArrayHashMap(comptime V: type) type
Builtin hashmap for strings as keys.
Functions
fn capacity(self: Self) usize
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 clearRetainingCapacity(self: *Self) void
Clears the map but retains the backing allocation for future use.
fn clone(self: Self) !Self
Create a copy of the hash map which can be modified separately. The copy uses t…
Create a copy of the hash map which can be modified separately. The copy uses the same context and allocator as this instance.
fn cloneWithAllocator(self: Self, allocator: Allocator) !Self
Create a copy of the hash map which can be modified separately. The copy uses t…
Create a copy of the hash map which can be modified separately. The copy uses the same context as this instance, but the specified allocator.
fn cloneWithAllocatorAndContext(self: Self, allocator: Allocator, ctx: anytype) !ArrayHashMap(K, V, @TypeOf(ctx), store_hash)
Create a copy of the hash map which can be modified separately. The copy uses t…
Create a copy of the hash map which can be modified separately. The copy uses the specified allocator and context.
fn cloneWithContext(self: Self, ctx: anytype) !ArrayHashMap(K, V, @TypeOf(ctx), store_hash)
Create a copy of the hash map which can be modified separately. The copy uses t…
Create a copy of the hash map which can be modified separately. The copy uses the same allocator as this instance, but the specified context.
fn deinit(self: *Self) void
Frees the backing allocation and leaves the map in an undefined state. Note tha…
Frees the backing allocation and leaves the map in an undefined state. Note that this does not free keys or values. You must take care of that before calling this function, if it is needed.
fn ensureTotalCapacity(self: *Self, new_capacity: usize) !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: usize) !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 fetchOrderedRemove(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. The entry is removed from the underlying array by shifting all elements forward thereby maintaining the current ordering.fn fetchPut(self: *Self, key: K, value: V) !?KV
Inserts a new
Entry
into the hash map, returning the previous one, if any.fn getEntry(self: Self, key: K) ?Entry
Finds pointers to the key and value storage associated with a key.
fn getOrPut(self: *Self, key: K) !GetOrPutResult
If key exists this function cannot fail. If there is an existing item with `key…
fn getOrPutAdapted(self: *Self, key: anytype, ctx: anytype) !GetOrPutResult
No documentation provided.
fn getOrPutAssumeCapacity(self: *Self, key: K) GetOrPutResult
If there is an existing item with
key
, then the resultEntry
pointer points…If there is an existing item with
key
, then the resultEntry
pointer points to it, and found_existing is true. Otherwise, puts a new item with undefined value, and theEntry
pointer points 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
No documentation provided.
fn init(allocator: Allocator) Self
Create an ArrayHashMap instance which will use a specified allocator.
fn iterator(self: *const Self) Iterator
Returns an iterator over the pairs in this map. Modifying the map may invalidat…
Returns an iterator over the pairs in this map. Modifying the map may invalidate this iterator.
fn keys(self: Self) []K
Returns the backing array of keys in this map. Modifying the map may invalidate…
Returns the backing array of keys in this map. Modifying the map may invalidate this array.
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 orderedRemove(self: *Self, key: K) bool
If there is an
Entry
with a matching key, it is deleted from the hash map. Th…If there is an
Entry
with a matching key, it is deleted from the hash map. The entry is removed from the underlying array by shifting all elements forward, thereby maintaining the current ordering. Returns true if an entry was removed, false otherwise.fn orderedRemoveAt(self: *Self, index: usize) void
Deletes the item at the specified index in
entries
from the hash map. The ent…Deletes the item at the specified index in
entries
from the hash map. The entry is removed from the underlying array by shifting all elements forward, thereby maintaining the current ordering.fn put(self: *Self, key: K, value: V) !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) !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 reIndex(self: *Self) !void
Rebuilds the key indexes. If the underlying entries has been modified directly, …
Rebuilds the key indexes. If the underlying entries has been modified directly, users can call
reIndex
to update the indexes to account for these new entries.fn sort(self: *Self, sort_ctx: anytype) void
Sorts the entries and then rebuilds the index.
sort_ctx
must have this method…Sorts the entries and then rebuilds the index.
sort_ctx
must have this method:fn lessThan(ctx: @TypeOf(ctx), a_index: usize, b_index: usize) bool
fn swapRemoveAt(self: *Self, index: usize) void
Deletes the item at the specified index in
entries
from the hash map. The ent…Deletes the item at the specified index in
entries
from the hash map. The entry is removed from the underlying array by swapping it with the last element.
Values
Data | undefined | The Data type used for the MultiArrayList backing this map |
DataList | undefined | The MultiArrayList type backing this map |
Entry | undefined | Pointers to a key and value in the backing store of this map. Modifying the key… |
GetOrPutResult | undefined | getOrPut variants return this structure, with pointers to the backing store and… |
Hash | undefined | The stored hash type, either u32 or void. |
Iterator | undefined | An Iterator over Entry pointers. |
KV | undefined | A KV pair which has been copied out of the backing store |
Unmanaged | undefined | The ArrayHashMapUnmanaged type using the same settings as this managed map. |