sekineh / binary-heap-plus-rs

Enhancement over Rust's `std::collections::BinaryHeap`. Supports other than max heap.
MIT License
56 stars 18 forks source link

Binary Heap that allows for interior mutability #41

Open Wasabi375 opened 1 year ago

Wasabi375 commented 1 year ago

This isn't really an issue with this repo so feel free to close this if you want.

I'm currently in the need for a binary heap that allows mutating the values stored within and then updating the heap accordingly. Since I couldn't find any implementation I started creating my own based on this repository.

Instead of just storing values I store key-value pairs. This allows me to implement get, get_mut, contains_key, etc. You can think of it as a mix between your implementation and HashMap (which I use internally).

My implementation can be found here: https://github.com/Wasabi375/mut-binary-heap

Why did I not just create a PR for this repo?

The changes I wanted to make require quite a large overhall of the API to support key-value pairs. I feel like there is both a usecase for your simpler implementation and mine and therefor a PR is not enough.

Why do I post here?

This is mostly a friendly heads up that I created this fork. If anyone here finds this and wants to look over my changes, feel free to do so. Any feedback is welcome.

Current Status

The main implementation is working. However I still need to change all tests to the new API and provide usefull traits like Into, From, etc. Also I have not yet published my fork to crates.io. I will do so, once I have the tests ready and also post an update here (unless you close this issue first).

Any changes that I want to see in this repo?

Not really. Of cause I would love a shoutout in the readme once I publish my crate, but that is obviously up to you. Other than that I will of port any bugfixes (if I find any bugs) or at least create an issue here.

Thanks for this greate repo.

It was a nice starting point, even if it is mostly an extension to the standard library implementation.

Wasabi375 commented 1 year ago

I just published v0.1.0 of the mut-binary-heap crate: https://crates.io/crates/mut-binary-heap There is still some work to do, but I fell compfortable to publish the crate in the current state. This will also most likely be my last update post here, as not to spam this repository.