Reset the xar iterator index to 0 for easy reuse

This commit is contained in:
Shane Shrybman
2026-02-20 11:28:50 -05:00
parent 109d68d022
commit baaea5c1e6

View File

@@ -476,6 +476,7 @@ Advance the iterator and returns the next element.
*/
array_iterate_by_val :: proc(it: ^Array_Iterator($T, $SHIFT)) -> (val: T, idx: int, ok: bool) {
if it.idx >= it.xar.len {
it.idx = 0
return
}
val = array_get(it.xar, it.idx)
@@ -497,6 +498,7 @@ Advance the iterator and returns a pointer to the next element.
*/
array_iterate_by_ptr :: proc(it: ^Array_Iterator($T, $SHIFT)) -> (val: ^T, idx: int, ok: bool) {
if it.idx >= it.xar.len {
it.idx = 0
return
}
val = array_get_ptr(it.xar, it.idx)