/*
 * Java Genetic Algorithm Library (@__identifier__@).
 * Copyright (c) @__year__@ Franz Wilhelmstötter
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * Author:
 *    Franz Wilhelmstötter (franz.wilhelmstoetter@gmail.com)
 */
package io.jenetics.prog.regression;

import java.util.AbstractList;
import java.util.stream.Stream;

/**
 * @author <a href="mailto:franz.wilhelmstoetter@gmail.com">Franz Wilhelmstötter</a>
 * @version !__version__!
 * @since !__version__!
 */
final class Samples extends AbstractList<Sample> {
	private final Sample[] _samples;

	private final double[][] _arguments;
	private final double[] _results;

	Samples(final Sample[] samples) {
		_samples = samples;

		_arguments = Stream.of(samples)
			.map(Sample::arguments)
			.toArray(double[][]::new);

		_results = Stream.of(samples)
			.mapToDouble(Sample::result)
			.toArray();
	}

	double[][] arguments() {
		return _arguments;
	}

	double[] results() {
		return _results;
	}

	@Override
	public Sample get(int index) {
		return _samples[index];
	}

	@Override
	public int size() {
		return _samples.length;
	}

}

@@ -775,16 +775,45 @@
 ssion;%0A%0A
+import java.io.Serializable;%0A
 import j
@@ -835,16 +835,16 @@
 ctList;%0A
-
 import j
@@ -1060,17 +1060,92 @@
 Sample%3E 
-%7B
+implements Serializable %7B%0A%09private static final long serialVersionUID = 1L;%0A
 %0A%09privat
@@ -1333,24 +1333,24 @@
 of(samples)%0A
+
 %09%09%09.map(Samp
@@ -1356,21 +1356,16 @@
 ple::arg
-ument
 s)%0A%09%09%09.t

Make 'Samples' serializable.