From 6ebffeb8f7df78e7b9467f65176c4570ffcf361d Mon Sep 17 00:00:00 2001 From: HEMANTH M <128402149+hemanth0525@users.noreply.github.com> Date: Mon, 2 Sep 2024 20:43:32 +0530 Subject: [PATCH] Add findDuplicates --- .../apache/commons/collections4/ListUtils.java | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/src/main/java/org/apache/commons/collections4/ListUtils.java b/src/main/java/org/apache/commons/collections4/ListUtils.java index b3dd237060..ff19fc8876 100644 --- a/src/main/java/org/apache/commons/collections4/ListUtils.java +++ b/src/main/java/org/apache/commons/collections4/ListUtils.java @@ -24,7 +24,6 @@ import java.util.Iterator; import java.util.List; import java.util.Objects; -import java.util.Set; import org.apache.commons.collections4.bag.HashBag; import org.apache.commons.collections4.functors.DefaultEquator; @@ -189,19 +188,7 @@ public static List fixedSizeList(final List list) { * @since 4.5.0-M3 */ public static List findDuplicates(final List list) { - Objects.requireNonNull(list, "The input list must not be null."); - - Set seen = new HashSet<>(); - Set duplicates = new HashSet<>(); - List result = new ArrayList<>(); - - for (E element : list) { - if (!seen.add(element) && duplicates.add(element)) { - result.add(element); - } - } - - return result; + return CollectionUtils.duplicateList(list); } /**