I have a loop where I walk over the items of one arraylist and gather additional items that I need to walk over (think of exploring a graph). At the end of each loop I want to move the discovered_items to the items_to_explore arraylist and "reset" or "clear" the discovered_items arraylist. But not sure how to do this effectively?
for (items_to_explore.items) |item| {
...
try discovered_items.append(new_item);
...
}
items_to_explore = discovered_items;
discovered_items.clearRetainingCapacity();