DoxigAlpha

Function parameters

Parameters

#
self:*Self
key:anytype
key_ctx:anytype
ctx:Context

Type definitions in this namespace

Types

#

Functions in this namespace

Functions

#
StringHashMap
Builtin hashmap for strings as keys.
StringHashMapUnmanaged
Key memory is managed by the caller.
HashMap
General purpose hash table.
HashMapUnmanaged
A HashMap based on open addressing and linear probing.

= 80

Values

#

Source

Implementation

#
pub fn getOrPutContextAdapted(self: *Self, allocator: Allocator, key: anytype, key_ctx: anytype, ctx: Context) Allocator.Error!GetOrPutResult {
    {
        self.pointer_stability.lock();
        defer self.pointer_stability.unlock();
        self.growIfNeeded(allocator, 1, ctx) catch |err| {
            // If allocation fails, try to do the lookup anyway.
            // If we find an existing item, we can return it.
            // Otherwise return the error, we could not add another.
            const index = self.getIndex(key, key_ctx) orelse return err;
            return GetOrPutResult{
                .key_ptr = &self.keys()[index],
                .value_ptr = &self.values()[index],
                .found_existing = true,
            };
        };
    }
    return self.getOrPutAssumeCapacityAdapted(key, key_ctx);
}