From 9e64a3cb81d66793e0147d1b6f4b39a6caa24f62 Mon Sep 17 00:00:00 2001 From: Thomas Neidhart Date: Mon, 12 Jan 2015 14:06:07 +0000 Subject: [PATCH] [COLLECTIONS-544] Documented runtime complexity of CollectionUtils.retainAll(Collection, Collection). Thanks to Oswaldo Olivo. git-svn-id: https://svn.apache.org/repos/asf/commons/proper/collections/trunk@1651098 13f79535-47bb-0310-9956-ffa450edef68 --- src/changes/changes.xml | 3 +++ .../org/apache/commons/collections4/CollectionUtils.java | 6 ++++++ 2 files changed, 9 insertions(+) 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