Actually, it was stupid of me to handle a non-RandomAccess list differently,

as they still implement get() and however they do that internally
is bound to be more efficient than doing the same thing through an
Iterator.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3367 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Ray Greenwell
2005-02-24 06:52:09 +00:00
parent a107aef489
commit 8491496226
@@ -24,7 +24,6 @@ package com.threerings.util;
import java.util.Iterator;
import java.util.List;
import java.util.Random;
import java.util.RandomAccess;
import com.samskivert.util.IntListUtil;
@@ -152,10 +151,6 @@ public class RandomUtil
public static Object pickRandom (List values)
{
int size = values.size();
if (!(values instanceof RandomAccess)) {
return pickRandom(values.iterator(), size);
}
if (size == 0) {
throw new IllegalArgumentException(
"Must have at least one element [size=" + size + "]");
@@ -173,10 +168,6 @@ public class RandomUtil
public static Object pickRandom (List values, Object skip)
{
int size = values.size();
if (!(values instanceof RandomAccess)) {
return pickRandom(values.iterator(), size, skip);
}
if (size < 2) {
throw new IllegalArgumentException(
"Must have at least one element [size=" + size + "]");