diff --git a/src/changes/changes.xml b/src/changes/changes.xml index d03bd5bce..fd3832a6c 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -22,8 +22,11 @@ + + Added clarifying javadoc wrt runtime complexity of "CollectionBag#retainAll". + - Clarify JavaDoc of MultiKey getKey() and size() + Clarify JavaDoc of MultiKey getKey() and size(). Added methods "removeAll(...)" and "retainAll(...)" to "CollectionUtils" that perform diff --git a/src/main/java/org/apache/commons/collections4/bag/CollectionBag.java b/src/main/java/org/apache/commons/collections4/bag/CollectionBag.java index bf53c61eb..73d02e89e 100644 --- a/src/main/java/org/apache/commons/collections4/bag/CollectionBag.java +++ b/src/main/java/org/apache/commons/collections4/bag/CollectionBag.java @@ -186,11 +186,17 @@ public final class CollectionBag extends AbstractBagDecorator { /** * (Change) - * Remove any members of the bag that are not in the given - * collection, not respecting cardinality. That is, any object - * in the given collection coll will be retained in the - * bag with the same number of copies prior to this operation. All - * other objects will be completely removed from this bag. + * Remove any members of the bag that are not in the given collection, + * not respecting cardinality. That is, any object in the given + * collection coll will be retained in the bag with the same + * number of copies prior to this operation. All other objects will be + * completely removed from this bag. + *

+ * This implementation iterates over the elements of this bag, checking + * each element in turn to see if it's contained in coll. + * If it's not contained, it's removed from this bag. As a consequence, + * it is advised to use a collection type for coll that provides + * a fast (e.g. O(1)) implementation of {@link Collection#contains(Object)}. * * @param coll the collection to retain * @return true if this call changed the collection