A case for valueless AA's?

David Nadlinger see at klickverbot.at
Wed Mar 30 07:42:33 PDT 2011


On 3/30/11 3:59 PM, dsimcha wrote:
> == Quote from David Nadlinger (see at klickverbot.at)'s article
>> On 3/30/11 5:02 AM, dsimcha wrote:
>>> […] Furthermore, most programs will probably want a hash set.
>> First of all, I agree that we really want to have a hash set in Phobos.
>> I think that a first implementation wouldn't even need to support
>> advanced operations like union, intersection, etc., but we should really
>> have some kind of set in the standard library which doesn't look plain
>> ugly (recently, I quickly needed some set implementation and abused AAs
>> for it, but this isn't a serious option).
>
> I was thinking an easy implementation of sets would be to abuse AAs using the
> void[0][KeyType] trick under the hood.  We could even make a type that wraps any
> AA conforming to the canonical compile time interface and makes a set, using this
> trick.

Yes, that's what I was thinking about as well, and I really think just 
using AAs under the hood would be fine for an initial implementation.

I'm considering writing up a patch for std.container myself (at least I 
certainly will if my Thrift project was accepted, because I'd rather 
target a »canonical« HashSet implementation there), but as I am unsure 
about what design to use (final classes?), I refrained from it so far.

David


More information about the Digitalmars-d mailing list