RFR: 8314502: Change the comparator taking version of GrowableArray::find to be a template method [v3]
Afshin Zafari
azafari at openjdk.org
Thu Sep 7 07:06:42 UTC 2023
On Tue, 29 Aug 2023 02:58:11 GMT, Quan Anh Mai <qamai at openjdk.org> wrote:
> This is similar to `std::find_if` and should be just:
>
> ```
> template<class UnaryPredicate>
> int find_if(UnaryPredicate p) const {
> for (int i = 0; i < _len; i++) {
> if (p(_data[i])) {
> return i;
> }
> }
> return -1;
> }
> ```
>
> Regarding the current approach, the comparator should take a `const E&` instead of an `E`, and the token passed in should be `const` also.
Thank you @merykitty for this comment.
It is fixed now.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/15418#issuecomment-1709587729
More information about the serviceability-dev
mailing list