A case for valueless AA's?

dsimcha dsimcha at yahoo.com
Wed Mar 30 06:59:57 PDT 2011


== 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.

> I vaguely remember you having an optimized AA library, David. Does it
> contain something of interest for a pure set implementation as well, or
> is it strictly tailored towards hash maps?

Strictly hash maps (though see above).  This is mostly optimized for very large
AAs that will be created and destroyed frequently.  The optimizations are with
regard to memory management.  For lookups it's actually slower than the builtin AA
b/c it's not as cache efficient.


More information about the Digitalmars-d mailing list