Lets a Bucket_Array be used in a for loop over its live elements, in bucket and slot order; it_index numbers the elements visited, 0, 1, 2, ... with free slots skipped.
it_index, the second name in for value, index: array, is a visit count, not a slot number and not a
Bucket_Locator: after a removal it no longer matches what array[n] accepts. Keep the Bucket_Locator from
bucket_array_add when you need to address an element.
for * gives pointers, for < goes backwards, and remove value; (with value the loop's variable, it by default)
deletes the current element, as bucket_array_remove would. Adding while iterating may or may not visit the new element.
array: Bucket_Array(string, 2);
for string.["a", "b", "c"] bucket_array_add(*array, it);
for name, index: array {
if name == "b" remove name;
}
assert(array.count == 2);
for name, index: array assert(name == ifx index == 0 then "a" else "c");
bucket_array_reset(*array);for_expansion :: (array: *$T/Bucket_Array, body: Code, flags: For_Flags)
Parameters
- array: *$T/Bucket_Array
- body: Code
- flags: For_Flags