Added a shuffle() that uses our internal random.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2950 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
package com.samskivert.util;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -142,6 +143,14 @@ public class Randoms
|
||||
return (float)_r.nextGaussian() * dev + mean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shuffle the specified list using our Random.
|
||||
*/
|
||||
public void shuffle (List<?> list)
|
||||
{
|
||||
Collections.shuffle(list, _r);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pick a random element from the specified Iterator, or return <code>ifEmpty</code>
|
||||
* if it is empty.
|
||||
|
||||
Reference in New Issue
Block a user