webit.script.lang.iter.IntAscIter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of webit-script Show documentation
Show all versions of webit-script Show documentation
a template-like script and engine, all writen with Java.
The newest version!
// Copyright (c) 2013-2014, Webit Team. All Rights Reserved.
package webit.script.lang.iter;
import java.util.NoSuchElementException;
import webit.script.lang.Iter;
/**
*
* @author Zqq
*/
public final class IntAscIter implements Iter {
private final int from;
private final int to;
private int current;
public IntAscIter(int int1, int int2) {
if (int1 < int2) {
from = int1;
to = int2;
} else {
from = int2;
to = int1;
}
current = from - 1;
}
public boolean hasNext() {
return current < to;
}
public Integer next() {
if (current < to) {
return ++current;
} else {
throw new NoSuchElementException("no more next");
}
}
public boolean isFirst() {
return current == from;
}
public int index() {
return current - from;
}
}