fn IndexedMap(comptime I: type, comptime V: type, comptime Ext: ?fn (type) type) type
A map from keys to values, using an index lookup. Uses a bitfield to track presence and a dense array of values. This type does no allocation and can be copied by value.
Functions
fn fetchPut(self: *Self, key: Key, value: Value) ?Value
Sets the value associated with the key in the map, and returns the old value. …
Sets the value associated with the key in the map, and returns the old value. If the key was not in the map, returns null.
fn fetchRemove(self: *Self, key: Key) ?Value
Removes a key from the map, and returns the old value. If the key was not in th…
Removes a key from the map, and returns the old value. If the key was not in the map, returns null.
fn get(self: Self, key: Key) ?Value
Gets the value associated with a key. If the key is not in the map, returns nul…
Gets the value associated with a key. If the key is not in the map, returns null.
fn getAssertContains(self: Self, key: Key) Value
Gets the value associated with a key, which must exist in the map.
fn getPtr(self: *Self, key: Key) ?*Value
Gets the address of the value associated with a key. If the key is not in the m…
Gets the address of the value associated with a key. If the key is not in the map, returns null.
fn getPtrAssertContains(self: *Self, key: Key) *Value
Gets the address of the value associated with a key. The key must be present in…
Gets the address of the value associated with a key. The key must be present in the map.
fn getPtrConst(self: *const Self, key: Key) ?*const Value
Gets the address of the const value associated with a key. If the key is not in…
Gets the address of the const value associated with a key. If the key is not in the map, returns null.
fn iterator(self: *Self) Iterator
Returns an iterator over the map, which visits items in index order. Modificati…
Returns an iterator over the map, which visits items in index order. Modifications to the underlying map may or may not be observed by the iterator, but will not invalidate it.
fn put(self: *Self, key: Key, value: Value) void
Adds the key to the map with the supplied value. If the key is already in the m…
Adds the key to the map with the supplied value. If the key is already in the map, overwrites the value.
fn putUninitialized(self: *Self, key: Key) *Value
Adds the key to the map with an undefined value. If the key is already in the m…
Adds the key to the map with an undefined value. If the key is already in the map, the value becomes undefined. A pointer to the value is returned, which should be used to initialize the value.