public CachingFunction(Function<long[],T> otherFunc) { this.otherFunc = otherFunc; lastValue = createOutput(); lastPoint = null; }
@Override public void compute(long[] point, T output) { if (lastPoint == null) { lastPoint = point.clone(); otherFunc.compute(point, lastValue); } else if (!Arrays.equals(point,lastPoint)) { recordInput(point); otherFunc.compute(point, lastValue); } output.setValue(lastValue); }
@Override public CachingFunction<T> copy() { return new CachingFunction<T>(otherFunc.copy()); }
@Override public void compute(long[] point, T output) { if (lastPoint == null) { lastPoint = point.clone(); otherFunc.compute(point, lastValue); } else if (!Arrays.equals(point,lastPoint)) { recordInput(point); otherFunc.compute(point, lastValue); } output.setValue(lastValue); }
@Override public CachingFunction<T> copy() { return new CachingFunction<T>(otherFunc.copy()); }
public CachingFunction(Function<long[],T> otherFunc) { this.otherFunc = otherFunc; lastValue = createOutput(); lastPoint = null; }