Re: Math.random()
- From: "Jeff Higgins" <oohiggins@xxxxxxxxx>
- Date: Mon, 25 Feb 2008 19:41:04 -0500
Jeff Higgins wrote:
Oops! having just read RedGrittyBrick's & Patricia's comments;
with a size argument of 1,000,000 I get +14 million iterations.
Scratch this one. :(
Thanks.
public static class NoDuplicateListOfRandomIntegers {
private static Random rand = new Random();
public static List<Integer> getRandomList(int size, int low, int high)
{
if(high <= size) {
throw new IllegalArgumentException();
}
Set<Integer> integers = new HashSet<Integer>();
while(integers.size() < size) {
integers.add(rand.nextInt(high - low + 1 ) + low);
}
List<Integer> ret = new ArrayList<Integer>();
ret.addAll(integers);
return ret;
}
}
}
.
- References:
- Math.random()
- From: maya
- Re: Math.random()
- From: maya
- Re: Math.random()
- From: Jeff Higgins
- Math.random()
- Prev by Date: Re: Math.random()
- Next by Date: Re: listing dirs in current webapp...
- Previous by thread: Re: Math.random()
- Next by thread: Re: Math.random()
- Index(es):