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" <[EMAIL PROTECTED]>
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to