On Thursday, 2 April 2020 at 12:59:06 UTC, AlexM wrote:
Please explain me whats wrong with binery heap?!!!

This has nothing to do with binaryheap and all to do with writeln.
writeln recognizes b and h as ranges, and prints them by iterating over each element, which advances the range to the end. You can see that the following actually prints what you expect:

```
     writeln(b[]);   // [1, 2, 3, 4, 7, 9, 10, 14, 8, 16]
     writeln(h.dup); // [1, 2, 3, 4, 7, 8, 9, 10, 14, 16]
     writeln(h.length); // 10
     h.insert(21);
     writeln(h.dup); // [1, 2, 3, 4, 7, 8, 9, 10, 14, 16, 21]
     writeln(h.length); // 11
```


Reply via email to