com.happy3w.toolkits.iterator.LongRangeIterator Maven / Gradle / Ivy
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