No longer pick from arrays.
Per the wailing and gnashing of teeth in response to7e51d4cand7bb7ee2, 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:
@@ -176,18 +176,6 @@ public class Randoms
|
|||||||
return pickPluck(iterable, ifEmpty, false);
|
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
|
* 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
|
* <code>ifEmpty</code> if no mapping has a weight greater than <code>0</code>. Each
|
||||||
|
|||||||
Reference in New Issue
Block a user