Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@www.apache.org Received: (qmail 85809 invoked from network); 10 Mar 2005 23:55:25 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 10 Mar 2005 23:55:25 -0000 Received: (qmail 64814 invoked by uid 500); 10 Mar 2005 23:55:22 -0000 Delivered-To: apmail-jakarta-commons-dev-archive@jakarta.apache.org Received: (qmail 64778 invoked by uid 500); 10 Mar 2005 23:55:22 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 64765 invoked by uid 99); 10 Mar 2005 23:55:22 -0000 X-ASF-Spam-Status: No, hits=1.8 required=10.0 tests=DNS_FROM_RFC_ABUSE,DNS_FROM_RFC_POST X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: local policy) Received: from smtp802.mail.ukl.yahoo.com (HELO smtp802.mail.ukl.yahoo.com) (217.12.12.139) by apache.org (qpsmtpd/0.28) with SMTP; Thu, 10 Mar 2005 15:55:21 -0800 Received: from unknown (HELO SCOLEBOURNE) (commons-dev@jakarta.apache.org@217.44.67.172 with poptime) by smtp802.mail.ukl.yahoo.com with SMTP; 10 Mar 2005 23:55:18 -0000 Message-ID: <004201c525cc$6fac0df0$ac432cd9@SCOLEBOURNE> From: "Stephen Colebourne" To: "Jakarta Commons Developers List" References: Subject: Re: [Collections] Random iterator? Date: Thu, 10 Mar 2005 23:54:02 -0000 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.2180 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 X-Antivirus: avast! (VPS 0510-0, 08/03/2005), Outbound message X-Antivirus-Status: Clean X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N 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" > 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