Package io.jenetics.prog.regression
Class SampleBuffer<T>
- java.lang.Object
-
- io.jenetics.prog.regression.SampleBuffer<T>
-
- All Implemented Interfaces:
Sampling<T>
public final class SampleBuffer<T> extends Object implements Sampling<T>
This class holds the actual sample values which are used for the symbolic regression example. This class is thread-safe and can be used in a producer-consumer setup. You can add single sample values (add(Sample)) or a list (addAll(Collection)) of new values. These values will be made available for evaluation after an explicit call of thepublish()method.- Since:
- 6.0
- Version:
- 6.0
- Author:
- Franz Wilhelmstötter
- Implementation Note:
- This class is thread-safe.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface io.jenetics.prog.regression.Sampling
Sampling.Result<T>
-
-
Constructor Summary
Constructors Constructor Description SampleBuffer(int size)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(Sample<T> sample)Adding a new sample point to the buffer.voidaddAll(Collection<? extends Sample<T>> samples)The the given sample points to the buffer.Sampling.Result<T>eval(Tree<? extends Op<T>,?> program)Evaluates the givenprogramtree with its sample points.intpublish()Making the current sample points available for theeval(Tree)function.
-
-
-
Constructor Detail
-
SampleBuffer
public SampleBuffer(int size)
-
-
Method Detail
-
add
public void add(Sample<T> sample)
Adding a new sample point to the buffer. You need to explicitly callpublish()to make it available for theeval(Tree)method.- Parameters:
sample- the sample point to add- Throws:
NullPointerException- if the givensamplepoint isnull
-
addAll
public void addAll(Collection<? extends Sample<T>> samples)
The the given sample points to the buffer. You need to explicitly callpublish()to make it available for theeval(Tree)method.- Parameters:
samples- the samples to add to the buffer- Throws:
NullPointerException- if the givensamplesisnull
-
publish
public int publish()
Making the current sample points available for theeval(Tree)function.- Returns:
- the number of published sample points
-
-