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

Add helper method for taking the k smallest elements in an iterator #473

Merged
merged 13 commits into from Dec 14, 2020
Merged

Add helper method for taking the k smallest elements in an iterator #473

merged 13 commits into from Dec 14, 2020

Commits on Oct 2, 2020

  1. Copy the full SHA
    46a739f View commit details
    Browse the repository at this point in the history
  2. Copy the full SHA
    51670c9 View commit details
    Browse the repository at this point in the history
  3. Copy the full SHA
    e71977e View commit details
    Browse the repository at this point in the history
  4. Copy the full SHA
    11b54cc View commit details
    Browse the repository at this point in the history
  5. Copy the full SHA
    b0443e0 View commit details
    Browse the repository at this point in the history
  6. k_smallest: Document the equivalence with self.sorted().take(k)

    Consistency with `Iterator::take` is the rationale for returning
    less than `k` elements when the input is too short.
    nbraud committed Oct 2, 2020
    Copy the full SHA
    d292fa0 View commit details
    Browse the repository at this point in the history
  7. Copy the full SHA
    7aadb1e View commit details
    Browse the repository at this point in the history
  8. Add generic test comparing k_smallest(k) and sorted().take(k)

    Instantiate the test over all unsigned integer types
    nbraud committed Oct 2, 2020
    Copy the full SHA
    036a451 View commit details
    Browse the repository at this point in the history
  9. Copy the full SHA
    900f1e8 View commit details
    Browse the repository at this point in the history
  10. test_std::k_smallest: Avoid allocating too much memory

    By limiting k and m to be u16, we use at most 2¹⁶ sizeof(u64) = 512 kiB
    for each allocated array and heap (at most 1MiB total for k_smallest_range)
    nbraud committed Oct 2, 2020
    Copy the full SHA
    f31b617 View commit details
    Browse the repository at this point in the history
  11. k_smallest: Work around suboptimality in peek_mut

    See rust-lang/rust#75974
    
    Co-authored-by: nicoo <nicoo@debian.org>
    SkiFire13 and nbraud committed Oct 2, 2020
    Copy the full SHA
    45e5a64 View commit details
    Browse the repository at this point in the history
  12. Copy the full SHA
    11b2058 View commit details
    Browse the repository at this point in the history
  13. Copy the full SHA
    f28ffd0 View commit details
    Browse the repository at this point in the history