You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by GitBox <gi...@apache.org> on 2021/04/02 01:21:37 UTC

[GitHub] [kafka] cmccabe commented on a change in pull request #10456: MINOR: support ImplicitLinkedHashCollection#sort

cmccabe commented on a change in pull request #10456:
URL: https://github.com/apache/kafka/pull/10456#discussion_r606026209



##########
File path: clients/src/main/java/org/apache/kafka/common/utils/ImplicitLinkedHashCollection.java
##########
@@ -676,4 +678,18 @@ final int numSlots() {
     public Set<E> valuesSet() {
         return new ImplicitLinkedHashCollectionSetView();
     }
+
+    public void sort(Comparator<E> comparator) {
+        ArrayList<E> array = new ArrayList<>();
+        Iterator<E> iterator = iterator();
+        while (iterator.hasNext()) {
+            E e = iterator.next();
+            iterator.remove();
+            array.add(e);
+        }
+        array.sort(comparator);
+        for (E e : array) {
+            add(e);

Review comment:
       The addAll for AbstractCollection is just a simple `for` loop.




-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org