Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@www.apache.org Received: (qmail 13327 invoked from network); 7 Jul 2005 19:00:12 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 7 Jul 2005 19:00:12 -0000 Received: (qmail 14758 invoked by uid 500); 7 Jul 2005 19:00:08 -0000 Delivered-To: apmail-jakarta-commons-dev-archive@jakarta.apache.org Received: (qmail 14688 invoked by uid 500); 7 Jul 2005 19:00:08 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: 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 14673 invoked by uid 99); 7 Jul 2005 19:00:07 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 07 Jul 2005 12:00:07 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [216.68.127.190] (HELO carmanconsulting.com) (216.68.127.190) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 07 Jul 2005 12:00:07 -0700 Received: from CARMANI9300 (carmanconsulting.com [127.0.0.1]) by carmanconsulting.com (8.13.1/8.13.1) with ESMTP id j67J044P017843 for ; Thu, 7 Jul 2005 15:00:05 -0400 Message-Id: <200507071900.j67J044P017843@carmanconsulting.com> From: "James Carman" To: "'Jakarta Commons Developers List'" Subject: RE: [collections] reference counting Date: Thu, 7 Jul 2005 15:00:14 -0400 MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook, Build 11.0.6353 In-Reply-To: <200507071858.j67IwncL017787@carmanconsulting.com> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 Thread-Index: AcWDJacTi08k3oj2Qb6bF5ZAAznpbgAACeSgAAAO4RA= X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Oops. Sorry! I didn't see the rest of your message. Apparently, you already found the aforementioned method. My mistake! -----Original Message----- From: James Carman [mailto:james@carmanconsulting.com] Sent: Thursday, July 07, 2005 2:59 PM To: 'Jakarta Commons Developers List' Subject: RE: [collections] reference counting Nope. The remove(Object o) method removes ALL occurrences of the object from the Bag. There is a remove(Object o, int nCopies) method available that you might want to try (using a value of 1 of course). Hope that helps. -----Original Message----- From: Torsten Curdt [mailto:tcurdt@apache.org] Sent: Thursday, July 07, 2005 2:57 PM To: Jakarta Commons Developers List Subject: Re: [collections] reference counting Torsten Curdt wrote: >>Are you thinking of a Bag? > > > Doh! That's it ...thanks :) Hm... org.apache.commons.collections.bag.HashBag bag = new org.apache.commons.collections.bag.HashBag(); bag.add("a"); System.out.println(bag.getCount("a")); bag.add("a"); System.out.println(bag.getCount("a")); bag.remove("a"); System.out.println(bag.getCount("a")); bag.remove("a"); System.out.println(bag.getCount("a")); gives 1 2 0 0 but I'd expect 1 2 1 0 this is because the remove(obj) is not delegating to a remove(obj,1) but is a full remove. ...so I have to extend that class. IMO having remove(obj) -> remove(obj,1) removeAll(obj) removeAll() would make more sense. My 2 cents cheers -- Torsten --------------------------------------------------------------------- To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-dev-help@jakarta.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-dev-help@jakarta.apache.org