Asssociative Array by Key-Value-Pair
Steven Schveighoffer via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Dec 16 08:56:20 PST 2014
On 12/16/14 11:47 AM, "Nordlöw" wrote:
> On Tuesday, 16 December 2014 at 16:08:09 UTC, Steven Schveighoffer wrote:
>> I can never ever see a reason to implement 2 different ways to
>> traverse the elements, just to piss off people?
>>
>> If you make a PR that adds that to documentation, I will pull it if it
>> makes you feel better. I don't think it hurts, but don't think it's
>> worth my time to make such a PR.
>>
>> -Steve
>
> I can do PR for adding
>
> https://github.com/nordlow/justd/blob/master/range_ex.d#L527
>
> to Phobos.
>
> Were should I put it/them?
I think to be clear, the PR I said I will pull is for the documentation
update. A doc change has no effect on the code.
I will certainly review one that adds iteration of both key and value
(as that is pretty much a free addition given the existing code), but it
will have to go through normal review process.
Note, the range you have referenced would not be accepted as it requires
an unnecessary AA lookup for the value, and it requires access to phobos
(this should be added to druntime). Take a look at object.di and see how
the byKey and byValue ranges work. It would be trivial to add a byPair
range (don't really like that name). The large controversy is regarding
how it returns the "front" element.
It would have to satisfy 3 requirements I think:
1. I should be able to do foreach(k, v; r) on it.
2. I should be able to access both key and value separately for each
element.
3. It cannot depend on phobos.
-Steve
More information about the Digitalmars-d-learn
mailing list