outer and inner indices to 0.advanceToNext method to find the next available element:
outer if inner is out of bounds for the current sub-vector.outer until a non-empty sub-vector is found.inner to point to it.hasNext, call advanceToNext and return whether the current indices point to a valid element.next, return the element at the current indices, then increment inner and call advanceToNext to prepare for the next call.