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

Rewrite Heap.rs #188

Closed
k12ish opened this issue Apr 5, 2021 · 4 comments
Closed

Rewrite Heap.rs #188

k12ish opened this issue Apr 5, 2021 · 4 comments

Comments

@k12ish
Copy link

k12ish commented Apr 5, 2021

This trivial test fails:

#[test]
fn test_empty_heap() {
    let mut heap = MaxHeap::new::<i32>();
    assert_eq!(heap.next(), None)
}
---- data_structures::heap::tests::test_empty_heap stdout ----
thread 'data_structures::heap::tests::test_empty_heap' panicked at 'attempt to subtract with
overflow', src/data_structures/heap.rs:117:9

Other big issues:

  • Vec contains a length meaning that count is unneeded
  • The trait bound Default can be entirely removed with zero-based indexing, saving memory and making the implementation more flexible

I am more than happy to enact these changes, if that is acceptable to you.

@stale
Copy link

stale bot commented Aug 18, 2021

This issue has been automatically marked as abandoned because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Aug 18, 2021
@siriak
Copy link
Member

siriak commented Aug 18, 2021

Hi, you can make a PR to fix that and I'll get it reviewed and merged. Thanks for sharing!

@stale stale bot removed the stale label Aug 18, 2021
@pdogr
Copy link
Contributor

pdogr commented Aug 31, 2021

Hi I made a PR to fix this. Let me know if any other changes are required.
Thanks!

@siriak
Copy link
Member

siriak commented Aug 31, 2021

Cool, thanks! Feel free to make more PRs if you want to fix something else

@siriak siriak closed this as completed Aug 31, 2021
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

No branches or pull requests

3 participants