Asssociative Array by Key-Value-Pair

"Nordlöw" via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Dec 16 09:30:28 PST 2014


On Tuesday, 16 December 2014 at 16:56:20 UTC, Steven 
Schveighoffer wrote:
>> 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

Got it.


More information about the Digitalmars-d-learn mailing list