// 
// Decompiled by Procyon v0.6.0
// 

package com.hypixel.hytale.builtin.hytalegenerator.iterators;

import javax.annotation.Nonnull;
import java.util.Iterator;
import it.unimi.dsi.fastutil.ints.IntIterator;

public class BackwardIntIterator implements IntIterator, Iterator<Integer>
{
    private int min;
    private int current;
    
    public BackwardIntIterator(final int min, final int maxExclusive) {
        if (min > maxExclusive) {
            throw new IllegalArgumentException("Start greater than end.");
        }
        this.min = min;
        this.current = maxExclusive;
    }
    
    private BackwardIntIterator() {
    }
    
    @Override
    public boolean hasNext() {
        return this.current > this.min;
    }
    
    @Override
    public int nextInt() {
        return --this.current;
    }
    
    @Nonnull
    @Override
    public Integer next() {
        final int n = this.current - 1;
        this.current = n;
        return n;
    }
    
    @Nonnull
    public Integer getCurrent() {
        return this.current;
    }
    
    @Nonnull
    public BackwardIntIterator clone() {
        final BackwardIntIterator clone = new BackwardIntIterator();
        clone.current = this.current;
        clone.min = this.min;
        return clone;
    }
}
