Le 27/09/2016 à 01:14, Gilles a écrit :

>>> * Shuffling algorithm (cf. Commons Math's "o.a.c.m.MathArrays"),
>>
>> This should go in the ArrayUtils class of commons-lang, with a
>> java.util.Random parameter.
> 
> I don't get that.
> The idea is to parameterize the utilities with a "UniformRandomProvider"
> instance.

My suggestion is to add two methods to ArrayUtils in commons-lang for
each primitive type and Object (and maybe a couple more if we want to
shuffle only a subset of the array):

   ArraysUtils.shuffle(Object[] array)
   ArraysUtils.shuffle(Object[] array, java.util.Random rnd)

And if we want to shuffle with a random generator from commons-rng, we
simply convert the UniformRandomProvider into a java.util.Random using
the adapter:

   RandomProvider rng = RandomSource.create(...);
   ArraysUtils.shuffle(array, new JDKRandomAdapter(rng));

or

   RandomProvider rng = RandomSource.create(...);
   ArraysUtils.shuffle(array, rng.asRandom());

Emmanuel Bourg


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org

Reply via email to