commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stephen Colebourne" <scolebou...@btopenworld.com>
Subject Re: [Collections] Random iterator?
Date Thu, 10 Mar 2005 23:54:02 GMT
We don't have such a method or iterator at present. I would like to keep 
[collections] for deterministic not random effects if possible.

Stephen


----- Original Message ----- 
From: "Hernan Silberman" <hsilberm@pdi.com>
> In my unit and load tests, I often find myself retrieving a collection of
> objects from a service, and selecting a random one from the collection. 
> Seems
> like a common use case (for testing anyhow) and I don't think there's any
> support in java.util Collections for, say, fetching a random item out of a 
> Set.
> It's easy enough to code by hand, but I was wondering if it's already done
> somewhere in commons-collections.  A Random iterator would be really cool.
>
> I suppose:
>
> List theList = new ArrayList( someCollection );
> Collections.shuffle( theList );
> Iterator theIt = theList.iterator();
>
> works fine too..
>
> thnx...
> hernan


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message