A graph data structure usable in @safe pure nothrow functions

w0rp via Digitalmars-d digitalmars-d at puremagic.com
Sun May 25 12:13:06 PDT 2014


On Sunday, 25 May 2014 at 17:30:52 UTC, FG wrote:
> On 2014-05-25 16:39, w0rp wrote:
>> I have been wanting graph types which can be used in @safe 
>> pure nothrow functions. The big blocker on this was what 
>> associative arrays could offer.
>> The current associative array implementation couldn't get me 
>> all the way there, so I wrote my own hashmap type.
>
> get and setDefault are nice, but can be easily done as small 
> UFCS wrappers around the "element in array" expression.
> What was blocking you in the current implementation of 
> associative arrays?
> Can't it be fixed without having to come up with a custom map 
> type?

My main blocker was that byKey and byValue functions on 
associative arrays weren't usable in @safe pure nothrow 
functions. So implementing my own gave me ranges I could use for 
doing the right things. The setDefault implementation is just 
kind of an added bonus.


More information about the Digitalmars-d mailing list