No longer pick from arrays.

Per the wailing and gnashing of teeth in response to 7e51d4c and 7bb7ee2,
I'll do the extra legwork to keep my bits in a List despite java handing
them to me as an array.
This commit is contained in:
David Hoover
2011-08-23 13:33:11 -07:00
parent 7e51d4c624
commit b76ab3cdac
@@ -176,18 +176,6 @@ public class Randoms
return pickPluck(iterable, ifEmpty, false);
}
/**
* Pick a random element from the specified array, or return <code>ifEmpty</code>
* if it is empty.
*
* @throws NullPointerException if the array is null.
*/
public <T> T pick (T[] array, T ifEmpty)
{
int size = array.length;
return (size == 0) ? ifEmpty : array[_r.nextInt(size)];
}
/**
* Pick a random <em>key</em> from the specified mapping of weight values, or return
* <code>ifEmpty</code> if no mapping has a weight greater than <code>0</code>. Each