![JAR search and dependency download from the Maven repository](/logo.png)
com.fillumina.performance.util.interval.AbstractBuildableInterval Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of performance-tools Show documentation
Show all versions of performance-tools Show documentation
Configurable tool to easily compare performances of different code
snippets and to take performance telemetry of a running application.
The newest version!
package com.fillumina.performance.util.interval;
import java.io.Serializable;
/**
*
* @author Francesco Illuminati
*/
public abstract class AbstractBuildableInterval
implements BuildableInterval, Serializable {
private static final long serialVersionUID = 1L;
protected T first, last, step, current;
private int index;
protected abstract boolean isLessThan(final T smaller, final T bigger);
/**
* Use this formula:
* result = first + step * index
.
*
* Thought more time-consuming than a simple addition it allows for less
* errors (i.e. in case of floating point numbers).
*/
protected abstract T calculateCurrent(final T first,
final T step, final int index);
@Override
public void setFirst(final T first) {
this.first = first;
}
@Override
public void setLast(final T last) {
this.last = last;
}
@Override
public void setStep(final T step) {
this.step = step;
}
@Override
public boolean hasNext() {
return current == null || isLessThan(current, last);
}
@Override
public T next() {
current = (current == null) ?
first : calculateCurrent(first, step, index);
index++;
return current;
}
@Override
public void remove() {
throw new UnsupportedOperationException("Not supported yet.");
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy