Pass the array index into the iterator

Include the current index in the workqueue iterator, so that it can be used to replace both `each` loops and `each_with_index` loops.