is it possible to sort a float range ?
mw
mingwu at gmail.com
Thu Jun 24 00:47:28 UTC 2021
On Thursday, 24 June 2021 at 00:32:31 UTC, Steven Schveighoffer
wrote:
> On 6/23/21 7:07 PM, someone wrote:
>> On Wednesday, 23 June 2021 at 22:46:28 UTC, Steven
>> Schveighoffer wrote:
>>
>>> Use the `release` method:
>>>
>>> ```d
>>> return lnumRange.sort!(...).release;
>>> ```
>>>
>>
>> Fantastic, issue solved, I previously used sort ascending even
>> descending but first time on floats.
>>
>> So I went and searched phobos docs:
>>
>> auto release();
>> Releases the controlled range and returns it.
>>
>> Not much clarification there.
>>
>> Can you elaborate a bit if possible Steve ?
>
> I think the purpose behind it is to say "here, now you have the
> original range back, so I won't guarantee it's sorted any more."
I for one still don't understand.
guarantee? are you saying without the `release()` call, the
sorted-ness is somehow guaranteed?
> I'm pretty sure it also clears out the source range in the
> sorted range, so you can no longer use the sortedness
> functions, but that's easily circumvented using `save`.
This `SortedRange` definitely need better documentation. E.g.
users can easily convert their `sort()` code to D from Java or
Python code after reading the doc.
> I can't really defend the purpose/implementation of
> `SortedRange`, it's something in Phobos that I've complained
> about extensively in the past.
(Sure, I'm not blaming you.)
More information about the Digitalmars-d-learn
mailing list