[Feature Request] Adding to D lang "set" built-in

Andrej Mitrovic andrej.mitrovich at gmail.com
Sun May 6 15:42:16 PDT 2012


On 5/7/12, H. S. Teoh <hsteoh at quickfur.ath.cx> wrote:
> you may be better off adapting D's AA implementation
> to have an AA that consists of just keys.

Yeah I do that in my code right now. It's pretty easy, just write an
some opApply/opBinary functions, add to!string(innerhash.keys) for
good measure and you're set (heh, set).

> Basically, you still have the
> hash table and buckets, just without the value field in each slot. (I
> wonder if it's possible for the new AA implementation to support this by
> specifying void as the value type.)

I think that can be done now with void[0], e.g.:

void[0][int] set;

I guess the way to add keys is to use a stub variable:
void[0][int] set;
void[0] val;
set[1] = val;

But I'm not sure how well serialization libraries can handle this
type, for my code I just use int[Key] in a wrapper struct.


More information about the Digitalmars-d mailing list