⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 integeriterator.java

📁 该原代码是实现机器学习中条件随机场模型的Java代码
💻 JAVA
字号:
/**
 * 
 */
package lcrf.stuff;

import java.util.Iterator;
import java.util.NoSuchElementException;

/**
 * @author bgutmann
 * 
 */
public class IntegerIterator implements Iterator<Integer> {
    private int next;

    private int mininclusive;

    private int maxexclusive;

    public IntegerIterator(int maxexclusive) {
        this(0, maxexclusive);
    }

    public IntegerIterator(int mininclusive, int maxexclusive) {
        next = mininclusive;
        this.mininclusive = mininclusive;
        this.maxexclusive = maxexclusive;
    }

    public boolean hasNext() {
        return next < maxexclusive;
    }

    public Integer next() {
        if (next < maxexclusive) {
            Integer result = new Integer(next);
            next++;
            return result;
        }
        throw new NoSuchElementException();
    }

    public void pushBack() {
        if (next == mininclusive)
            throw new IllegalStateException("Next was never called before.");
        next--;
    }

    public void remove() {
        throw new UnsupportedOperationException();
    }

    public void reset() {
        next = mininclusive;
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -