core/container/handle_map
container_handle_map
Types
7Dynamic_Handle_Map
Dynamic_Handle_Map :: struct {}SourceDynamic_Handle_Map_Iterator
Dynamic_Handle_Map_Iterator :: struct {}SourceAn iterator for a handle map.
Handle16
Handle16 :: struct {
idx: u8,
gen: u8,
}SourceDefault 16-bit Handle type which can be used for handle maps which only need a maximum of 254 (1<<8 - 2) items
Handle32
Handle32 :: struct {
idx: u16,
gen: u16,
}SourceDefault 32-bit Handle type which can be used for handle maps which only need a maximum of 65534 (1<<16 - 2) items
Handle64
Handle64 :: struct {
idx: u32,
gen: u32,
}SourceDefault 64-bit Handle type which can be used for handle maps which only need a maximum of 4294967294 (1<<32 - 2) items
Static_Handle_Map
Static_Handle_Map :: struct {}SourceStatic_Handle_Map_Iterator
Static_Handle_Map_Iterator :: struct {}SourceAn iterator for a handle map.
Procedures
20dynamic_add
dynamic_add :: proc(m: ^D, item: T, loc = #caller_location) -> (handle: Handle_Type, err: runtime.Allocator_Error)Sourcedynamic_cap
dynamic_cap :: proc(m: D) -> (uint)Sourcedynamic_clear
dynamic_clear :: proc(m: ^D)Sourcedynamic_destroy
dynamic_destroy :: proc(m: ^D)Sourcedynamic_get
dynamic_get :: proc(m: ^D, h: Handle_Type) -> (^T, bool)Sourcedynamic_init
dynamic_init :: proc(m: ^D, allocator: runtime.Allocator)Sourcedynamic_is_valid
dynamic_is_valid :: proc(m: ^D, h: Handle_Type) -> (bool)Sourcedynamic_iterate
dynamic_iterate :: proc(it: ^DHI) -> (val: ^T, h: Handle_Type, ok: bool)SourceIterate over a handle map. It will skip over unused item slots (e.g. handle.idx == 0).
Usage:
it := hm.dynamic_iterator_make(&the_dynamic_handle_map)
for item, handle in hm.iterate(&it) {
...
}dynamic_iterator_make
dynamic_iterator_make :: proc(m: ^D) -> (Dynamic_Handle_Map_Iterator(D))SourceMakes an iterator from a handle map.
dynamic_len
dynamic_len :: proc(m: D) -> (uint)SourceReturns the number of possibly valid items in the handle map.
dynamic_remove
dynamic_remove :: proc(m: ^D, h: Handle_Type, loc = #caller_location) -> (found: bool, err: runtime.Allocator_Error)Sourcestatic_add
static_add :: proc(m: ^H, item: T) -> (handle: Handle_Type, ok: bool)Sourceadd a value of type T to the handle map. This will return a pointer to the item and an optional boolean to check for validity.
static_cap
static_cap :: proc(m: H) -> (uint)SourceReturns the capacity of the items in a handle map. This is equivalent to N-1 as the zero value is reserved for the zero-value sentinel.
static_clear
static_clear :: proc(m: ^H)Sourceclear the handle map by zeroing all of the memory. Internally this does not do m^ = {} but rather uses intrinsics.mem_zero explicitly improve performance.
static_get
static_get :: proc(m: ^H, h: Handle_Type) -> (^T, bool)Sourceget a stable pointer of type ^T by resolving the handle h. If the handle is not valid, then nil, false is returned.
static_is_valid
static_is_valid :: proc(m: H, h: Handle_Type) -> (bool)SourceReturns true when the handle h is valid relating to the handle map.
static_iterate
static_iterate :: proc(it: ^HI) -> (val: ^T, h: Handle_Type, ok: bool)SourceIterate over a handle map. It will skip over unused item slots (e.g. handle.idx == 0).
Usage:
it := hm.iterator_make(&the_handle_map)
for item, handle in hm.iterate(&it) {
...
}static_iterator_make
static_iterator_make :: proc(m: ^H) -> (Static_Handle_Map_Iterator(H))SourceMakes an iterator from a handle map.
static_len
static_len :: proc(m: H) -> (uint)SourceReturns the number of possibly valid items in the handle map.
static_remove
static_remove :: proc(m: ^H, h: Handle_Type) -> (bool)Sourceremove an item from the handle map from the handle h.
Procedure Groups
9add
add :: proc{static_add, dynamic_add}Sourcecap
cap :: proc{static_cap, dynamic_cap}Sourceclear
clear :: proc{static_clear, dynamic_clear}Sourceget
get :: proc{static_get, dynamic_get}Sourceis_valid
is_valid :: proc{static_is_valid, dynamic_is_valid}Sourceiterate
iterate :: proc{static_iterate, dynamic_iterate}Sourceiterator_make
iterator_make :: proc{static_iterator_make, dynamic_iterator_make}Sourcelen
len :: proc{static_len, dynamic_len}Sourceremove
remove :: proc{static_remove, dynamic_remove}Source