digitalmars.D.learn - Binary heap: obtain a _reference_ to the front of the heap
- Johan Engelen (9/9) Sep 13 2016 In the binary heap documentation, I read that
- Nicholas Wilson (8/17) Sep 13 2016 What does
- Johan Engelen (3/22) Sep 14 2016 It copies the front of the heap on every iteration.
- Johan Engelen (5/10) Sep 15 2016 Answering myself here: the binary heap element type should be
In the binary heap documentation, I read that `BinaryHeap.front()` "Returns a copy of the front of the heap". [1] Is there no function to access the front of the heap without a copy? (micro-optimization) Thanks, Johan [1] https://dlang.org/phobos/std_container_binaryheap.html#.BinaryHeap.front
Sep 13 2016
On Tuesday, 13 September 2016 at 08:19:04 UTC, Johan Engelen wrote:In the binary heap documentation, I read that `BinaryHeap.front()` "Returns a copy of the front of the heap". [1] Is there no function to access the front of the heap without a copy? (micro-optimization) Thanks, Johan [1] https://dlang.org/phobos/std_container_binaryheap.html#.BinaryHeap.frontWhat does foreach(ref e; bh) { //... } do?
Sep 13 2016
On Tuesday, 13 September 2016 at 08:55:15 UTC, Nicholas Wilson wrote:On Tuesday, 13 September 2016 at 08:19:04 UTC, Johan Engelen wrote:It copies the front of the heap on every iteration.In the binary heap documentation, I read that `BinaryHeap.front()` "Returns a copy of the front of the heap". [1] Is there no function to access the front of the heap without a copy? (micro-optimization) Thanks, Johan [1] https://dlang.org/phobos/std_container_binaryheap.html#.BinaryHeap.frontWhat does foreach(ref e; bh) { //... } do?
Sep 14 2016
On Tuesday, 13 September 2016 at 08:19:04 UTC, Johan Engelen wrote:In the binary heap documentation, I read that `BinaryHeap.front()` "Returns a copy of the front of the heap". [1] Is there no function to access the front of the heap without a copy? (micro-optimization)Answering myself here: the binary heap element type should be cheap to copy, because it is going to be copied around a lot (for the common implementation on top of an array).
Sep 15 2016