All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.jonathanxd.iutils.iterator.IteratorUtil Maven / Gradle / Ivy

There is a newer version: 1.7
Show newest version
/*
 * 	TextLexer - Lexical Analyzer API for Java! 
 *     Copyright (C) 2016 TheRealBuggy/JonathanxD (https://github.com/JonathanxD/) 
 *
 * 	GNU GPLv3
 *
 *     This program is free software: you can redistribute it and/or modify
 *     it under the terms of the GNU Affero General Public License as published
 *     by the Free Software Foundation.
 *
 *     This program is distributed in the hope that it will be useful,
 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *     GNU Affero General Public License for more details.
 *
 *     You should have received a copy of the GNU Affero General Public License
 *     along with this program.  If not, see .
 */
package com.github.jonathanxd.iutils.iterator;

import java.util.Iterator;

/**
 * Created by jonathan on 08/02/16.
 */
public class IteratorUtil {

    public static void goTo(Iterator iterator, int index) {
        int x = 0;
        while(x != index) {
            if(!iterator.hasNext()) {
                throw new IndexOutOfBoundsException("Index out of bounds!");
            }
            iterator.next();
            ++x;
        }
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy