diff --git a/src/changes/changes.xml b/src/changes/changes.xml index deb08c46f..82931a6d5 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -22,6 +22,9 @@ + + Documented runtime complexity of "CollectionUtils#retainAll(Collection, Collection). + "AbstractHashedMap" still inherits from "AbstractMap", contrary to what the class javadoc stated. The inheritance will now be removed in v5.0. diff --git a/src/main/java/org/apache/commons/collections4/CollectionUtils.java b/src/main/java/org/apache/commons/collections4/CollectionUtils.java index 7c0b9ffdc..3303e3b6e 100644 --- a/src/main/java/org/apache/commons/collections4/CollectionUtils.java +++ b/src/main/java/org/apache/commons/collections4/CollectionUtils.java @@ -1883,6 +1883,12 @@ public class CollectionUtils { * in collection unless retain does not contain e, in which * case the cardinality is zero. This method is useful if you do not wish to modify * the collection c and thus cannot call c.retainAll(retain);. + *

+ * This implementation iterates over collection, checking each element in + * turn to see if it's contained in retain. If it's contained, it's added + * to the returned list. As a consequence, it is advised to use a collection type for + * retain that provides a fast (e.g. O(1)) implementation of + * {@link Collection#contains(Object)}. * * @param the type of object the {@link Collection} contains * @param collection the collection whose contents are the target of the #retailAll operation