Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Position max, min and minmax methods #412

Merged
merged 3 commits into from Mar 1, 2020

Conversation

tspiteri
Copy link
Contributor

The following nine methods are provided:

  • position_max, position_max_by_key, position_max_by; return Option<usize>
  • position_min, position_min_by_key, position_min_by; return Option<usize>
  • position_minmax, position_minmax_by_key, position_minmax_by; return MinMaxResult<usize>

The position_max and position_min methods are implemented using Iterator::enumerate and Iterator::max_by/min_by.

The position_minmax methods are implemented using Iterator::enumerate and minmax::minmax_impl rather than Itertools::minmax_by, so that the comparison constraint can be relaxed from Ord to PartialOrd, just like for the minmax methods.

Closes #410.

The max functions use Iterator::max_by, while the min functions use
Iterator::min_by.
The implementation uses minmax::minmax_impl rather than
Itertools::minmax_by, so that the comparison constraint is relaxed to
PartialOrd, just like for the minmax functions.
src/lib.rs Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
Co-Authored-By: Jack Wrenn <johnswrenn@gmail.com>
@jswrenn
Copy link
Member

jswrenn commented Mar 1, 2020

Thanks for the contribution!

bors r+

@bors
Copy link
Contributor

bors bot commented Mar 1, 2020

Build succeeded

@bors bors bot merged commit 7c96136 into rust-itertools:master Mar 1, 2020
@jswrenn jswrenn added this to the next milestone Mar 4, 2020
@tspiteri tspiteri deleted the position-max-min branch March 8, 2020 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature request: arg_min and arg_max
2 participants