vsop-479 commented on code in PR #15823:
URL: https://github.com/apache/lucene/pull/15823#discussion_r2986836998


##########
lucene/core/src/java/org/apache/lucene/util/PriorityQueue.java:
##########
@@ -174,6 +176,36 @@ public void addAll(Collection<T> elements) {
     }
   }
 
+  /**
+   * Similar to {@link #addAll(Collection)}, but supply an {@link Function} to 
transform element.
+   * This method should be preferred over calling {@link #addAll(Collection)}, 
when the type of
+   * param elements is different from the type of this {@link PriorityQueue}, 
since it doesn't
+   * require the caller to do the conversion at the call site.
+   */
+  public <S> void addAll(Collection<S> elements, Function<S, T> 
elementTransformer) {

Review Comment:
   > The goal is that PriorityQueue doesn't need to know anything about the 
translation logic. That all gets encapsulated behind the Iterator that is setup 
by the calling code. WDYT?
   
   +1. There is a minor issue with `public void addAll(Iterable<T> elements)`, 
the original `addAll` validate the size with `Collection#size` firstly. If we 
want keep this validation, maybe the caller need input the size of elements? 
like this:`public void addAll(Iterable<T> elements, int size)`?



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to