@Test public void create() { final List<Sample<Double>> points = List.of( Sample.ofDouble(1, 2, 3, 4), Sample.ofDouble(1, 2, 3, 4), Sample.ofDouble(1, 2, 3, 4), Sample.ofDouble(1, 2, 3, 4) ); final SampleList<Double> samples = new SampleList<>(points); final var result = samples.eval(MathExpr.parse("x + y + z - y").toTree()); for (var y : result.calculated()) { Assert.assertEquals(y.doubleValue(), 4.0); } }
@Override public Result<T> eval(final Tree<? extends Op<T>, ?> program) { @SuppressWarnings("unchecked") final T[] calculated = Stream.of(_arguments) .map(args -> Program.eval(program, args)) .toArray(size -> (T[])Array.newInstance(_type, size)); return Result.of(calculated, _results); }
SampleList extends AbstractList<Sample<T>> implements
		Sampling<T>,
		Serializable { @Override public Result<T> eval(final Tree<? extends Op<T>, ?> program) { @SuppressWarnings("unchecked") final T[] calculated = Stream.of(_arguments) .map(args -> Program.eval(program, args)) .toArray(size -> (T[])Array.newInstance(_type, size)); return Result.of(calculated, _results); } }
SampleList extends AbstractList<Sample<T>> implements
		Sampling<T>,
		Serializable { @Override public Result<T> eval(final Tree<? extends Op<T>, ?> program) { @SuppressWarnings("unchecked") final T[] calculated = Stream.of(_arguments) .map(args -> Program.eval(program, args)) .toArray(size -> (T[])Array.newInstance(_type, size)); return Result.of(calculated, _results); } @SuppressWarnings("unchecked")  SampleList(final List<Sample<T>> samples); }
SampleList extends AbstractList<Sample<T>> implements
		Sampling<T>,
		Serializable { @Override public Result<T> eval(final Tree<? extends Op<T>, ?> program) { @SuppressWarnings("unchecked") final T[] calculated = Stream.of(_arguments) .map(args -> Program.eval(program, args)) .toArray(size -> (T[])Array.newInstance(_type, size)); return Result.of(calculated, _results); } @SuppressWarnings("unchecked")  SampleList(final List<Sample<T>> samples); @Override Result<T> eval(final Tree<? extends Op<T>, ?> program); @Override Sample<T> get(int index); @Override int size(); }
SampleList extends AbstractList<Sample<T>> implements
		Sampling<T>,
		Serializable { @Override public Result<T> eval(final Tree<? extends Op<T>, ?> program) { @SuppressWarnings("unchecked") final T[] calculated = Stream.of(_arguments) .map(args -> Program.eval(program, args)) .toArray(size -> (T[])Array.newInstance(_type, size)); return Result.of(calculated, _results); } @SuppressWarnings("unchecked")  SampleList(final List<Sample<T>> samples); @Override Result<T> eval(final Tree<? extends Op<T>, ?> program); @Override Sample<T> get(int index); @Override int size();  }