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

com.happy3w.toolkits.iterator.LongRangeIterator Maven / Gradle / Ivy

There is a newer version: 1.2.0
Show newest version
package com.happy3w.toolkits.iterator;

public class LongRangeIterator implements IEasyIterator {
    protected long current;
    protected long end;
    protected long step;

    public LongRangeIterator(long start, long end) {
        this(start, end, 1L);
    }

    public LongRangeIterator(long start, long end, long step) {
        this.current = start;
        this.end = end;
        this.step = step;
    }


    @Override
    public boolean hasNext() {
        return step > 0 ? current < end : current > end;
    }

    @Override
    public Long next() {
        long result = current;
        current = current + step;
        return result;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy