Re: Why after writeln the binaryHeap become empty?

2019-06-18 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 19 June 2019 at 06:00:28 UTC, Jonathan M Davis wrote: On Tuesday, June 18, 2019 10:27:46 PM MDT lili via Do you known reason for why Dlang Range are consumed by iterating over them. I this design is strange. If you want an overview of ranges, you can watch this: https://www.

Re: Why after writeln the binaryHeap become empty?

2019-06-18 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, June 18, 2019 10:27:46 PM MDT lili via Digitalmars-d-learn wrote: > On Tuesday, 18 June 2019 at 17:25:51 UTC, Johannes Loher wrote: > > The result of heapify is a BinaryHeap, which is a range. writeln > > basically prints ranges by iterating over them and printing > > each element > >

Re: Why after writeln the binaryHeap become empty?

2019-06-18 Thread lili via Digitalmars-d-learn
On Tuesday, 18 June 2019 at 17:25:51 UTC, Johannes Loher wrote: The result of heapify is a BinaryHeap, which is a range. writeln basically prints ranges by iterating over them and printing each element (except for the types which are special cased, such as dynamic arrays etc.). However, ranges

Re: Why after writeln the binaryHeap become empty?

2019-06-18 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, June 18, 2019 9:45:33 AM MDT lili via Digitalmars-d-learn wrote: > Hi Guys: > see this code > ~~~ > int[] ar = [1,2,3,4,52,34,22]; > auto h = heapify(ar); > assert(h.length() == ar.length); > writeln("h:",h); > assert(h.empty()); > ~~~ > dmd v2.086.0 run al

Re: Why after writeln the binaryHeap become empty?

2019-06-18 Thread Johannes Loher via Digitalmars-d-learn
Am 18.06.19 um 17:45 schrieb lili: > Hi Guys: >    see this code > ~~~ >     int[] ar = [1,2,3,4,52,34,22]; >     auto h = heapify(ar); >     assert(h.length() == ar.length); >     writeln("h:",h); >     assert(h.empty()); > ~~~ > dmd v2.086.0  run all assert passed. Why? The result of heapify is

Why after writeln the binaryHeap become empty?

2019-06-18 Thread lili via Digitalmars-d-learn
Hi Guys: see this code ~~~ int[] ar = [1,2,3,4,52,34,22]; auto h = heapify(ar); assert(h.length() == ar.length); writeln("h:",h); assert(h.empty()); ~~~ dmd v2.086.0 run all assert passed. Why?