Claims a free slot and returns a pointer to it and its locator; the lower-level half of bucket_array_add.
The element is set to the default value of the type, or left uninitialized with $initialize set to false, in which
case the caller must write all of it.
array: Bucket_Array(int, 4);
slot, locator := find_and_occupy_empty_slot(*array);
assert(slot.* == 0 && array.count == 1);
slot.* = 9;
assert(bucket_array_find(*array, locator) == 9);
bucket_array_reset(*array);find_and_occupy_empty_slot :: (
array: *Bucket_Array,
$initialize := true
) -> (*array.type, Bucket_Locator)
Takes a free slot, allocating a new bucket when all are full. Returns a pointer to the slot and its locator.
Parameters
- array: *Bucket_Array
- $initialize := true
- set to
falseto leave the slot's bytes as they were.
Returns
- *array.type