garydgregory commented on code in PR #537:
URL:
https://github.com/apache/commons-collections/pull/537#discussion_r1740971210
##########
src/main/java/org/apache/commons/collections4/ListUtils.java:
##########
@@ -173,6 +174,36 @@ public static <E> List<E> fixedSizeList(final List<E>
list) {
return FixedSizeList.fixedSizeList(list);
}
+ /**
+ * Finds and returns a list of duplicate elements in the given list.
+ * <p>
+ * This method uses two sets: one for tracking seen elements and one for
+ * collecting duplicates. It iterates through the list once and collects
+ * duplicates in a result list.
+ * </p>
+ *
+ * @param <E> the type of elements in the list
+ * @param list the list to check for duplicates, must not be null
+ * @return a list of duplicate elements, or an empty list if no duplicates
are found
+ * @throws NullPointerException if the list is null
+ * @since 4.5.0-M3
+ */
+ public static <E> List<E> findDuplicates(final List<E> list) {
+ Objects.requireNonNull(list, "The input list must not be null.");
Review Comment:
@hemanth0525
If you replace the body of this (git master) method with:
```java
return IterableUtils.duplicateList(list);
```
You'll find that all tests pass.
So I don't think we need this method in this class.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]