vsop-479 commented on code in PR #15823:
URL: https://github.com/apache/lucene/pull/15823#discussion_r2992876874
##########
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:
> We'll hit the same AIOOB exception anyway in the for-each loop that's
populating the array
Indeed. That is what `PriorityQueue#add` do (when caller iterate their
elements to call ). So i removed the validation and implmented `public void
addAll(Iterable<T> elements)`.
--
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]