Invokes action for each element of the array in order, passing its index. Does not use GdxArray.iterator, so it does not allocate and can be safely nested. The array must not be structurally modified by action.