On 7/22/13 12:19 PM, Gilles wrote: > On Sun, 21 Jul 2013 20:40:42 -0700, Phil Steitz wrote: >> I would like to use getNatural and shuffle from RandomDataGenerator >> outside of that class (inside [math] I need to efficiently generate >> random n-m partitions of {0, ..., n + m - 1}). I think getNatural >> could go into MathArrays and shuffle could just be exposed by >> RandomDataGenerator. Any objections to making these public? (I >> promise to rewrite the javadoc for getNatural so it makes sense to >> non-logicians and I would even be OK with renaming it ;) > > "shuffle" could probably be useful in other contexts too. Various > versions could also be defined in "MathArrays": > > ---CUT--- > public enum Position { > /** Designates the beginning of the array (near index 0). */ > HEAD, > /** Designates the end of the array. */ > TAIL > } > > public static void shuffle(int[] list, > int start, > Position pos, > RandomGenerator rng) { > // ... > } > ---CUT--- > > And "double" versions: > > ---CUT--- > public static void shuffle(double[] list, > int start, > Position pos, > RandomGenerator rng) { > // ... > } > ---CUT--- > > And obvious overloads: e.g. > > ---CUT--- > public static void shuffle(double[] list, RandomGenerator rng) > public static void shuffle(double[] list) > ---CUT--- > > > The method in RandomDataGenerator would become a client: > > ---CUT--- > private void shuffle(int[] list, int end) { > MathArrays.shuffle(list, MathArrays.Position.TAIL, end, > getRandomGenerator()); > } > ---CUT---
+1 All that I need immediately is the int[] version that shuffles the entire array, but I agree that the above could prove useful and are natural. Phil > > > Regards, > Gilles > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org > For additional commands, e-mail: dev-h...@commons.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org For additional commands, e-mail: dev-h...@commons.apache.org