#About `BinaryHeap`'s `Hole` implementation

1 messages · Page 1 of 1 (latest)

hardy panther
#

After implementing my own binary heap, I went over to see what Rust's version does, and I met the Hole struct: https://doc.rust-lang.org/stable/src/alloc/collections/binary_heap.rs.html#1219-1274. Looking into it I wonder if it's not the same as just manipulating indices and swapping. Is it just a way to express better the semantics of what's happening in a safer way or does it do a different thing than using swap_unchecked directly on the slice? PD: my own implementation, which I'm comparing to Rust's own: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=cee546f16b6ba7c105c739e3e3f6f059

hardy panther
#

oh thank you

#

I thought the explanation was going to be in Hole's docs