Use method reference for the sampler

This commit is contained in:
aherbert 2022-12-02 13:56:34 +00:00
parent 9fcd3885dc
commit abb32b5a62
2 changed files with 2 additions and 22 deletions

View File

@ -218,16 +218,6 @@ public class EnumeratedIntegerDistribution extends AbstractIntegerDistribution {
*/
@Override
public DiscreteDistribution.Sampler createSampler(final UniformRandomProvider rng) {
return new DiscreteDistribution.Sampler() {
/** Delegate. */
private final EnumeratedDistribution<Integer>.Sampler inner =
innerDistribution.createSampler(rng);
/** {@inheritDoc} */
@Override
public int sample() {
return inner.sample();
}
};
return innerDistribution.createSampler(rng)::sample;
}
}

View File

@ -249,16 +249,6 @@ public class EnumeratedRealDistribution
/** {@inheritDoc} */
@Override
public ContinuousDistribution.Sampler createSampler(final UniformRandomProvider rng) {
return new ContinuousDistribution.Sampler() {
/** Delegate. */
private final EnumeratedDistribution<Double>.Sampler inner =
innerDistribution.createSampler(rng);
/** {@inheritDoc} */
@Override
public double sample() {
return inner.sample();
}
};
return innerDistribution.createSampler(rng)::sample;
}
}