You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by sc...@apache.org on 2003/12/03 02:02:32 UTC
cvs commit: jakarta-commons/collections/src/java/org/apache/commons/collections/bag AbstractMapBag.java
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