fn AutoArrayHashMapUnmanaged(comptime K: type, comptime V: type) type
An ArrayHashMapUnmanaged with default hash and equal functions. See AutoContext for a description of the hash and equal implementations.
Fields
entries: DataList = .{ },
It is permitted to access this field directly.
index_header: ?*IndexHeader = null,
When entries length is less than linear_scan_max
, this remains null
. Once entries length grows big enough, this field is allocated. There is an IndexHeader followed by an array of Index(I) structs, where I is defined by how many total indexes there are.
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 clearAndFree(self: *Self, allocator: Allocator) void
Clears the map and releases the backing allocation
fn clearRetainingCapacity(self: *Self) void
Clears the map but retains the backing allocation for future use.
fn clone(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 is allocated with the provided allocator.
fn deinit(self: *Self, allocator: Allocator) 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, allocator: Allocator, 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 ensureTotalCapacityContext(self: *Self, allocator: Allocator, new_capacity: usize, ctx: Context) !void
No documentation provided.
fn ensureUnusedCapacity(self: *Self, allocator: Allocator, additional_capacity: 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 ensureUnusedCapacityContext(self: *Self, allocator: Allocator, additional_capacity: usize, ctx: Context) !void
No documentation provided.
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 fetchOrderedRemoveContextAdapted(self: *Self, key: anytype, key_ctx: anytype, ctx: Context) ?KV
No documentation provided.
fn fetchPut(self: *Self, allocator: Allocator, key: K, value: V) !?KV
Inserts a new
Entry
into the hash map, returning the previous one, if any.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) !?KV
No documentation provided.
fn fetchSwapRemoveContextAdapted(self: *Self, key: anytype, key_ctx: anytype, ctx: Context) ?KV
No documentation provided.
fn getEntry(self: Self, key: K) ?Entry
Finds pointers to the key and value storage associated with a key.
fn getOrPut(self: *Self, allocator: Allocator, key: K) !GetOrPutResult
If key exists this function cannot fail. If there is an existing item with `key…
fn getOrPutAdapted(self: *Self, allocator: Allocator, key: anytype, key_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
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 key and value, and theEntry
pointers point to it. Caller must then initialize both the key and the value. If a new entry needs to be stored, this function asserts there is enough capacity to store it.fn getOrPutAssumeCapacityContext(self: *Self, key: K, ctx: Context) GetOrPutResult
No documentation provided.
fn getOrPutContext(self: *Self, allocator: Allocator, key: K, ctx: Context) !GetOrPutResult
No documentation provided.
fn getOrPutContextAdapted(self: *Self, allocator: Allocator, key: anytype, key_ctx: anytype, ctx: Context) !GetOrPutResult
No documentation provided.
fn getOrPutValue(self: *Self, allocator: Allocator, key: K, value: V) !GetOrPutResult
No documentation provided.
fn getOrPutValueContext(self: *Self, allocator: Allocator, key: K, value: V, ctx: Context) !GetOrPutResult
No documentation provided.
fn iterator(self: 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 orderedRemoveContextAdapted(self: *Self, key: anytype, key_ctx: anytype, ctx: Context) bool
No documentation provided.
fn promote(self: Self, allocator: Allocator) Managed
Convert from an unmanaged map to a managed map. After calling this, the promot…
Convert from an unmanaged map to a managed map. After calling this, the promoted map should no longer be used.
fn put(self: *Self, allocator: Allocator, 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 putAssumeCapacityContext(self: *Self, key: K, value: V, ctx: Context) void
No documentation provided.
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 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) !void
No documentation provided.
fn putNoClobber(self: *Self, allocator: Allocator, 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 putNoClobberContext(self: *Self, allocator: Allocator, key: K, value: V, ctx: Context) !void
No documentation provided.
fn reIndex(self: *Self, allocator: Allocator) !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 shrinkAndFreeContext(self: *Self, allocator: Allocator, new_len: usize, ctx: Context) void
No documentation provided.
fn shrinkRetainingCapacityContext(self: *Self, new_len: usize, ctx: Context) void
No documentation provided.
inline 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.fn swapRemoveContextAdapted(self: *Self, key: anytype, key_ctx: anytype, ctx: Context) bool
No documentation provided.