class CheckedIterator {

    @VisibleForTesting
    int advance(int numberToAdvance) throws T, IllegalArgumentException {
        checkArgument(numberToAdvance >= 0, "numberToAdvance must be nonnegative");
        int i;
        for (i = 0; i < numberToAdvance && hasNext(); i++) {
            next();
        }
        return i;
    }

}