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