Files
rust/src
bors efebe45cc0 Auto merge of #25856 - bluss:binary-heap-hole, r=Gankro
collections: Make BinaryHeap panic safe in sift_up / sift_down

Use a struct called Hole that keeps track of an invalid location
in the vector and fills the hole on drop.

I include a run-pass test that the current BinaryHeap fails, and the new
one passes.

NOTE: The BinaryHeap will still be inconsistent after a comparison fails. It will
not have the heap property. What we fix is just that elements will be valid
values.

This is actually a performance win -- the new code does not bother to write in `zeroed()`
values in the holes, it just leaves them as they were.

Net result is something like a 5% decrease in runtime for `BinaryHeap::from_vec`. This
can be further improved by using unchecked indexing (I confirmed it makes a difference,
not a surprise with the non-sequential access going on), but let's leave that for another PR.
Safety first 😉 

Fixes #25842
2015-05-28 20:16:08 +00:00
..
2015-05-26 12:11:46 -07:00
2015-05-27 11:19:02 +03:00
2015-05-15 16:04:01 -07:00
2015-05-15 16:04:01 -07:00
2015-05-15 16:04:01 -07:00
2015-04-29 08:55:31 -07:00
2015-05-19 19:36:10 +02:00
2015-05-28 12:51:01 -04:00
2015-05-15 16:04:01 -07:00
2015-05-11 15:05:57 -07:00