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
- 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 void
add(Sample<T> sample)
Adding a new sample point to the buffer.void
addAll(Collection<? extends Sample<T>> samples)
The the given sample points to the buffer.Sampling.Result<T>
eval(Tree<? extends Op<T>,?> program)
Evaluates the givenprogram
tree with its sample points.int
publish()
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 givensample
point 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 givensamples
isnull
-
publish
public int publish()
Making the current sample points available for theeval(Tree)
function.- Returns:
- the number of published sample points
-
-