How to use sets in D?

mark mark at qtrac.eu
Sat Feb 8 07:46:55 UTC 2020


On Friday, 7 February 2020 at 22:03:00 UTC, H. S. Teoh wrote:
> On Fri, Feb 07, 2020 at 07:37:08PM +0000, mark via 
> Digitalmars-d-learn wrote:
[snip]
> bool[E] works just fine.
[snip]
> Or you can wrap void[0][E] in a nice user-defined type that 
> gives nice set-like syntax.  But IMO, this is all overkill, and 
> adds needless complexity. Just use bool[E] or 
> std.container.rbtree. :-D

I didn't think bool[E] would be a win because although it is only 
one byte per item, it won't align so wouldn't it end up taking 4 
bytes of space anyway. The void[0][E] you showed is good, but, 
I'll try using the rbtree since I'd rather use an out-of-the-box 
collection.

Thanks for the replies.


More information about the Digitalmars-d-learn mailing list