Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@www.apache.org Received: (qmail 6904 invoked from network); 3 Dec 2003 01:02:36 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 3 Dec 2003 01:02:36 -0000 Received: (qmail 12550 invoked by uid 500); 3 Dec 2003 01:02:17 -0000 Delivered-To: apmail-jakarta-commons-dev-archive@jakarta.apache.org Received: (qmail 12496 invoked by uid 500); 3 Dec 2003 01:02:17 -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 12483 invoked by uid 500); 3 Dec 2003 01:02:17 -0000 Received: (qmail 12479 invoked from network); 3 Dec 2003 01:02:17 -0000 Received: from unknown (HELO minotaur.apache.org) (209.237.227.194) by daedalus.apache.org with SMTP; 3 Dec 2003 01:02:17 -0000 Received: (qmail 6889 invoked by uid 1529); 3 Dec 2003 01:02:32 -0000 Date: 3 Dec 2003 01:02:32 -0000 Message-ID: <20031203010232.6888.qmail@minotaur.apache.org> From: scolebourne@apache.org To: jakarta-commons-cvs@apache.org Subject: cvs commit: jakarta-commons/collections/src/java/org/apache/commons/collections/bag AbstractMapBag.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N scolebourne 2003/12/02 17:02:32 Modified: collections/src/java/org/apache/commons/collections/bag AbstractMapBag.java Log: Optimise the remove method on a bag Revision Changes Path 1.3 +11 -4 jakarta-commons/collections/src/java/org/apache/commons/collections/bag/AbstractMapBag.java Index: AbstractMapBag.java =================================================================== RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/bag/AbstractMapBag.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- AbstractMapBag.java 3 Dec 2003 00:49:38 -0000 1.2 +++ AbstractMapBag.java 3 Dec 2003 01:02:32 -0000 1.3 @@ -378,13 +378,20 @@ } /** - * Removes one copy of the specified object from the bag. + * Removes all copies of the specified object from the bag. * * @param object the object to remove * @return true if the bag changed */ public boolean remove(Object object) { - return remove(object, getCount(object)); + MutableInteger mut = (MutableInteger) map.get(object); + if (mut == null) { + return false; + } + modCount++; + map.remove(object); + size -= mut.value; + return true; } /** --------------------------------------------------------------------- To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-dev-help@jakarta.apache.org