Whats wrong with binery heap or i am not understand something?
Dennis
dkorpel at gmail.com
Thu Apr 2 13:23:29 UTC 2020
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
```
More information about the Digitalmars-d-learn
mailing list